:root {
  --ib-font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";

  --ib-bottom-nav-h: 72px;
  --ib-bottom-nav-gap: 12px;

  --ib-bg: #f6f8fb;
  --ib-surface: #ffffff;
  --ib-surface-2: #f2f5fb;
  --ib-text: #0f172a;
  --ib-muted: #64748b;
  --ib-border: rgba(15, 23, 42, 0.08);

  --ib-radius: 12px;
  --ib-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
  --ib-shadow-soft: 0 2px 8px rgba(15, 23, 42, 0.03);

  --ib-topbar-h: 56px;

  --ib-primary: #1e40af; /* azul */
  --ib-primary-2: #2563eb;
  --ib-danger: #dc2626;

  --ib-sidebar-bg: #0b1220;
  --ib-sidebar-text: rgba(255, 255, 255, 0.86);
  --ib-sidebar-muted: rgba(255, 255, 255, 0.55);
  --ib-sidebar-link: rgba(255, 255, 255, 0.86);
  --ib-sidebar-link-hover: rgba(255, 255, 255, 1);
  --ib-sidebar-link-bg: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] {
  /* Dracula-inspired */
  --ib-bg: #0f0f17;
  --ib-surface: #1b1b27;
  --ib-surface-2: #242437;
  --ib-text: #f8f8f2;
  --ib-muted: #b7b7c8;
  --ib-border: rgba(248, 248, 242, 0.08);

  --ib-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  --ib-shadow-soft: 0 2px 10px rgba(0, 0, 0, 0.25);

  --ib-primary: #bd93f9;
  --ib-primary-2: #ff79c6;
  --ib-danger: #ff5555;

  --ib-sidebar-bg: #171722;
  --ib-sidebar-text: rgba(248, 248, 242, 0.92);
  --ib-sidebar-muted: rgba(248, 248, 242, 0.60);
  --ib-sidebar-link: rgba(248, 248, 242, 0.92);
  --ib-sidebar-link-hover: rgba(248, 248, 242, 1);
  --ib-sidebar-link-bg: rgba(189, 147, 249, 0.12);
}

.ib-body {
  background: var(--ib-bg);
  color: var(--ib-text);
  font-family: var(--ib-font-sans);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Auth (Login) */
.ib-auth {
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    radial-gradient(1200px 600px at 10% 10%, color-mix(in oklab, var(--ib-primary) 18%, transparent) 0%, transparent 60%),
    radial-gradient(900px 500px at 90% 20%, color-mix(in oklab, var(--ib-primary-2) 16%, transparent) 0%, transparent 55%),
    var(--ib-bg);
}

.ib-auth-container {
  min-height: 100dvh;
  box-sizing: border-box;
  padding-block: clamp(14px, 3vh, 24px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ib-auth-row {
  width: 100%;
}

.ib-auth-shell {
  width: min(980px, 100%);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--ib-shadow);
}

.ib-auth-panel {
  background:
    radial-gradient(700px 450px at 30% 20%, color-mix(in oklab, var(--ib-primary) 22%, transparent) 0%, transparent 60%),
    color-mix(in oklab, var(--ib-surface) 84%, transparent);
  border-right: 1px solid var(--ib-border);
}

.ib-auth-panel-inner {
  padding: 34px;
}

.ib-auth-form-wrap {
  padding: 34px;
}

.ib-auth-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.ib-auth-mark {
  width: 96px;
  height: 96px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  background: color-mix(in oklab, var(--ib-surface) 74%, transparent);
  border: 1px solid var(--ib-border);
}

.ib-auth-mark img {
  width: 78px;
  height: 78px;
  object-fit: contain;
  object-position: center;
  display: block;
  filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.10));
}

.ib-auth-mark--sm {
  width: 72px;
  height: 72px;
  border-radius: 18px;
}

.ib-auth-mark--sm img {
  width: 56px;
  height: 56px;
}

.ib-auth-title {
  font-size: 1.6rem;
  font-weight: 800;
}

.ib-auth-subtitle {
  color: var(--ib-muted);
}

.ib-auth-bullets {
  display: grid;
  gap: 14px;
}

.ib-auth-form-wrap .h4 {
  letter-spacing: -0.01em;
}

@media (max-width: 576px) {
  .ib-auth-container {
    padding-block: 14px;
  }

  .ib-auth-shell {
    width: 100%;
  }

  .ib-auth-form-wrap {
    padding: 20px;
  }
}

@media (max-width: 991.98px) {
  .ib-auth-panel {
    border-right: 0;
    border-bottom: 1px solid var(--ib-border);
  }
}

.ib-input-group .input-group-text {
  background: color-mix(in oklab, var(--ib-surface) 70%, transparent);
  border-color: var(--ib-border);
  color: var(--ib-muted);
}

.ib-input-group .form-control {
  border-color: var(--ib-border);
}

.ib-input-group .form-control:focus {
  box-shadow: 0 0 0 0.2rem color-mix(in oklab, var(--ib-primary) 20%, transparent);
}

.ib-auth-hint {
  background: color-mix(in oklab, var(--ib-surface-2) 70%, transparent);
  border: 1px solid var(--ib-border);
  border-radius: 14px;
  padding: 12px 14px;
}

.ib-icon {
  font-size: 20px;
  line-height: 1;
  vertical-align: -0.2em;
}

.material-symbols-rounded {
  font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 24;
}

.ib-min-w-0 {
  min-width: 0;
}

.ib-dropdown-toggle::after {
  display: none;
}

.ib-dropdown-menu {
  background: var(--ib-surface);
  border: 1px solid var(--ib-border);
  border-radius: 14px;
  box-shadow: var(--ib-shadow-soft);
  padding: 6px;
  min-width: 220px;
}

.ib-dropdown-menu .dropdown-item {
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ib-text);
}

.ib-dropdown-menu .dropdown-item:hover {
  background: var(--ib-surface-2);
}

.ib-dropdown-menu .dropdown-divider {
  border-top-color: var(--ib-border);
  margin: 6px 0;
}

.ib-shell {
  height: 100dvh;
  overflow: hidden;
}

.ib-sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--ib-sidebar-bg);
  color: var(--ib-sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow: auto;
  transition: width 180ms ease, min-width 180ms ease;
}

main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

.ib-sidebar-header {
  height: var(--ib-topbar-h);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
  flex-shrink: 0;
}

.ib-brand-text {
  min-width: 0;
}

.ib-brand-title {
  font-weight: 700;
  color: var(--ib-sidebar-text);
}

.ib-brand-sub {
  font-size: 0.8rem;
  color: var(--ib-sidebar-muted);
}

.ib-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.10);
  color: var(--ib-sidebar-text);
}

.ib-logo-img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.25));
}

.ib-nav-section {
  padding: 10px 10px 6px 10px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ib-sidebar-muted);
}

.ib-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  margin: 4px 6px;
  border-radius: 10px;
  text-decoration: none;
  font-size: 0.925rem;
  color: var(--ib-sidebar-link);
}

.ib-nav-text {
  display: inline-block;
  min-width: 0;
}

.ib-nav-link:hover {
  background: var(--ib-sidebar-link-bg);
  color: var(--ib-sidebar-link-hover);
}

.ib-nav-toggle {
  position: relative;
}

.ib-nav-chevron {
  margin-left: auto;
  font-size: 20px;
  opacity: 0.9;
  transition: transform 160ms ease;
}

.ib-nav-toggle[aria-expanded="true"] .ib-nav-chevron {
  transform: rotate(180deg);
}

.ib-nav-sub {
  margin: 0 6px 6px 6px;
  padding-left: 34px;
}

.ib-nav-sublink {
  display: block;
  padding: 8px 10px;
  margin: 2px 0;
  border-radius: 10px;
  text-decoration: none;
  font-size: 0.9rem;
  color: color-mix(in oklab, var(--ib-sidebar-link) 92%, white);
}

.ib-nav-sublink:hover {
  background: var(--ib-sidebar-link-bg);
  color: var(--ib-sidebar-link-hover);
}

/* Offcanvas (menu mobile): sublinks sem recuo excessivo */
.ib-offcanvas .ib-nav-sub {
  margin: 0 0 6px 0;
  padding-left: 0;
}

.ib-offcanvas .ib-nav-sublink {
  margin: 4px 0;
  padding: 10px 12px;
  border: 1px solid color-mix(in oklab, var(--ib-border) 86%, transparent);
  background: color-mix(in oklab, var(--ib-surface) 94%, transparent);
}

.ib-nav-link.is-active {
  background: var(--ib-sidebar-link-bg);
  color: var(--ib-sidebar-link-hover);
}

/* ===== Chat ===== */
.ib-chat-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ib-chat-messages {
  border: 1px solid var(--ib-border);
  background: color-mix(in oklab, var(--ib-surface) 90%, transparent);
  border-radius: 16px;
  padding: 12px;
  height: min(64vh, 640px);
  overflow: auto;
}

@media (max-width: 991.98px) {
  .ib-chat-messages {
    height: min(62vh, 560px);
  }
}

.ib-chat-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ib-chat-msg {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: min(78%, 680px);
}

.ib-chat-msg--me {
  margin-left: auto;
  align-items: flex-end;
}

.ib-chat-bubble {
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid color-mix(in oklab, var(--ib-border) 86%, transparent);
  background: color-mix(in oklab, var(--ib-surface) 92%, transparent);
  white-space: pre-wrap;
  word-break: break-word;
}

.ib-chat-msg--me .ib-chat-bubble {
  background: color-mix(in oklab, var(--ib-primary) 18%, var(--ib-surface));
  border-color: color-mix(in oklab, var(--ib-primary) 28%, var(--ib-border));
}

.ib-chat-meta {
  font-size: 0.78rem;
  color: var(--ib-muted);
}

.ib-chat-composer {
  display: flex;
  gap: 10px;
}

.ib-chat-composer textarea {
  resize: none;
}

.ib-topbar {
  background: color-mix(in oklab, var(--ib-surface) 86%, transparent);
  border-bottom: 1px solid var(--ib-border);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
}

/* Logo na topbar (mobile): sem borda/sombra/fundo */
.ib-topbar-brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  padding: 0;
  margin-right: 6px;
  border: none;
  background: transparent;
}

.ib-topbar-brand-img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  display: block;
  border-radius: 0;
  filter: none;
  box-shadow: none;
}

.ib-topbar .container-fluid {
  height: var(--ib-topbar-h);
}

/* Logo gigante (defensivo): limita caso algum template exiba logo no conteúdo no mobile */
@media (max-width: 991.98px) {
  .ib-content img[src*="imagens/logo.png"] {
    max-width: min(320px, 82vw);
    max-height: 140px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    margin: 0 auto;
  }
}

/* ===== Toasts (mensagens do sistema) ===== */
.ib-toast-stack {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column-reverse; /* de baixo para cima */
  gap: 10px;
  max-width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}

.ib-toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 12px 10px;
  border-radius: 14px;
  border: 1px solid color-mix(in oklab, var(--ib-border) 85%, transparent);
  background: color-mix(in oklab, var(--ib-surface) 88%, transparent);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.10);
  backdrop-filter: blur(10px);
  color: var(--ib-text);
  position: relative;
  overflow: hidden;

  opacity: 0;
  transform: translateX(12px) translateY(8px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.ib-toast::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: color-mix(in oklab, var(--ib-muted) 60%, transparent);
}

.ib-toast.ib-toast--show {
  opacity: 1;
  transform: translateX(0) translateY(0);
}

.ib-toast.ib-toast--hide {
  opacity: 0;
  transform: translateX(120%) translateY(0);
}

.ib-toast-icon {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: color-mix(in oklab, var(--ib-surface-2) 70%, transparent);
  border: 1px solid color-mix(in oklab, var(--ib-border) 70%, transparent);
}

.ib-toast-icon .material-symbols-rounded {
  font-size: 20px;
  line-height: 1;
}

.ib-toast-body {
  flex: 1;
  line-height: 1.25;
  font-size: 0.9rem;
  font-weight: 550;
  letter-spacing: -0.01em;
}

.ib-toast-close {
  border: none;
  background: transparent;
  color: color-mix(in oklab, var(--ib-text) 70%, transparent);
  font-size: 20px;
  line-height: 1;
  padding: 0 6px;
  margin-left: 2px;
}

.ib-toast-close:hover {
  color: var(--ib-text);
}

/* Cores por categoria (compatível com flash do Flask: success/danger/warning/info) */
.ib-toast--success {
  border-color: color-mix(in oklab, #16a34a 30%, var(--ib-border));
}

.ib-toast--success::before {
  background: #16a34a;
}

.ib-toast--success .ib-toast-icon {
  background: color-mix(in oklab, #16a34a 16%, var(--ib-surface));
  border-color: color-mix(in oklab, #16a34a 30%, var(--ib-border));
  color: #16a34a;
}

.ib-toast--danger {
  border-color: color-mix(in oklab, var(--ib-danger) 35%, var(--ib-border));
}

.ib-toast--danger::before {
  background: var(--ib-danger);
}

.ib-toast--danger .ib-toast-icon {
  background: color-mix(in oklab, var(--ib-danger) 14%, var(--ib-surface));
  border-color: color-mix(in oklab, var(--ib-danger) 30%, var(--ib-border));
  color: var(--ib-danger);
}

.ib-toast--warning {
  border-color: color-mix(in oklab, #f59e0b 40%, var(--ib-border));
}

.ib-toast--warning::before {
  background: #f59e0b;
}

.ib-toast--warning .ib-toast-icon {
  background: color-mix(in oklab, #f59e0b 14%, var(--ib-surface));
  border-color: color-mix(in oklab, #f59e0b 30%, var(--ib-border));
  color: #b45309;
}

.ib-toast--info {
  border-color: color-mix(in oklab, #0ea5e9 35%, var(--ib-border));
}

.ib-toast--info::before {
  background: #0ea5e9;
}

.ib-toast--info .ib-toast-icon {
  background: color-mix(in oklab, #0ea5e9 14%, var(--ib-surface));
  border-color: color-mix(in oklab, #0ea5e9 30%, var(--ib-border));
  color: #0369a1;
}

html[data-theme="dark"] .ib-toast {
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.35);
  background: color-mix(in oklab, var(--ib-surface) 84%, transparent);
}

.ib-topbar-inner {
  height: var(--ib-topbar-h);
  padding: 0 16px;
}

.ib-page-title {
  font-weight: 700;
}

.ib-card {
  background: var(--ib-surface);
  border: 1px solid var(--ib-border);
  border-radius: var(--ib-radius);
  box-shadow: var(--ib-shadow-soft);
}

.ib-alert {
  border-radius: 12px;
}

.ib-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  /* espaço para bottom nav no mobile */
  padding-bottom: calc(var(--ib-bottom-nav-h) + 16px + env(safe-area-inset-bottom));
}

@media (min-width: 992px) {
  .ib-content {
    padding-bottom: 16px;
  }
}

.ib-btn-primary {
  background: var(--ib-primary);
  border: 1px solid var(--ib-primary);
  color: #fff;
}

html[data-theme="dark"] .ib-btn-primary {
  color: #16161f;
}

.ib-btn-primary:hover {
  background: var(--ib-primary-2);
  border-color: var(--ib-primary-2);
  color: #fff;
}

html[data-theme="dark"] .ib-btn-primary:hover {
  color: #16161f;
}

.ib-btn-secondary {
  background: transparent;
  border: 1px solid var(--ib-border);
  color: var(--ib-text);
}

.ib-btn-secondary:hover {
  background: var(--ib-surface-2);
  border-color: var(--ib-border);
  color: var(--ib-text);
}

.ib-btn-danger {
  background: transparent;
  border: 1px solid rgba(220, 38, 38, 0.35);
  color: var(--ib-danger);
}

.ib-btn-danger:hover {
  background: rgba(220, 38, 38, 0.10);
  border-color: rgba(220, 38, 38, 0.55);
  color: var(--ib-danger);
}

.ib-list-item {
  background: var(--ib-surface);
  color: var(--ib-text);
  border: 1px solid var(--ib-border);
}

.ib-offcanvas {
  background: var(--ib-surface);
  color: var(--ib-text);
}

.ib-nav-link--mobile {
  border: 1px solid var(--ib-border);
  background: var(--ib-surface);
  color: var(--ib-text);
}

.ib-nav-link--mobile:hover {
  background: var(--ib-surface-2);
  color: var(--ib-text);
}

.ib-avatar {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 800;
  background: var(--ib-surface-2);
  border: 1px solid var(--ib-border);
}

.ib-bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  min-height: var(--ib-bottom-nav-h);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));

  background: color-mix(in oklab, var(--ib-surface) 92%, transparent);
  border-top: 1px solid var(--ib-border);
  box-shadow: 0 -10px 28px rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(14px);
  z-index: 50;
}

.ib-bottom-nav-scroll {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  padding: 0 4px;
  scrollbar-width: none;
}

.ib-bottom-nav-scroll::-webkit-scrollbar {
  display: none;
}

.ib-bottom-link {
  flex: 0 0 auto;
  min-width: 76px;
  position: relative;
  border: none;
  background: transparent;
  text-decoration: none;
  color: var(--ib-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 6px;
  border-radius: 14px;

  scroll-snap-align: start;

  transition: background-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.ib-bottom-link i {
  font-size: 1.25rem;
  line-height: 1;
}

.ib-bottom-link span {
  font-size: 0.72rem;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ib-bottom-link:hover {
  color: var(--ib-text);
  background: var(--ib-surface-2);
}

.ib-bottom-link:active {
  transform: translateY(1px);
}

.ib-bottom-link:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ib-primary) 26%, transparent);
}

.ib-bottom-link.is-active {
  color: var(--ib-primary);
  background: color-mix(in oklab, var(--ib-primary) 12%, var(--ib-surface));
}

.ib-bottom-link.is-active::before {
  content: "";
  position: absolute;
  inset: 6px 10px;
  border-radius: 12px;
  background: linear-gradient(135deg,
    color-mix(in oklab, var(--ib-primary) 18%, transparent),
    color-mix(in oklab, var(--ib-primary-2) 12%, transparent)
  );
  z-index: -1;
}

.ib-bottom-link.is-active::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 6px;
  width: 18px;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--ib-primary), var(--ib-primary-2));
  opacity: 0.95;
}

.ib-bottom-link.is-active .material-symbols-rounded {
  font-variation-settings: 'FILL' 1, 'wght' 650, 'GRAD' 0, 'opsz' 24;
}

/* Destaque do botão central (Início) */
.ib-bottom-link--center {
  gap: 6px;
  color: var(--ib-muted);
  background: transparent;
  box-shadow: none;
}

.ib-bottom-link--center:hover {
  color: var(--ib-text);
  background: transparent;
}

.ib-bottom-center-orb {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  position: relative;

  background:
    radial-gradient(120% 120% at 25% 10%, rgba(255,255,255,0.72) 0%, rgba(255,255,255,0.18) 38%, rgba(255,255,255,0.06) 62%, rgba(255,255,255,0.02) 100%),
    color-mix(in oklab, var(--ib-surface) 65%, transparent);
  border: 1px solid color-mix(in oklab, var(--ib-border) 80%, transparent);
  box-shadow:
    0 10px 22px rgba(15, 23, 42, 0.10),
    inset 0 1px 0 rgba(255,255,255,0.55);
  backdrop-filter: blur(14px);
}

.ib-bottom-center-orb::after {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 999px;
  background: linear-gradient(135deg,
    rgba(255,255,255,0.18),
    rgba(255,255,255,0.02)
  );
  pointer-events: none;
}

.ib-bottom-link--center .material-symbols-rounded {
  font-variation-settings: 'FILL' 1, 'wght' 650, 'GRAD' 0, 'opsz' 24;
  color: var(--ib-primary);
}

.ib-bottom-link--center span:last-child {
  font-weight: 700;
}

.ib-bottom-link--center.is-active {
  color: var(--ib-primary);
  background: transparent;
}

.ib-bottom-link--center.is-active::after {
  display: none;
}

.ib-bottom-link--center.is-active::before {
  display: none;
}

.ib-bottom-link--center.is-active .ib-bottom-center-orb {
  background:
    radial-gradient(120% 120% at 25% 10%, rgba(255,255,255,0.55) 0%, rgba(255,255,255,0.16) 40%, rgba(255,255,255,0.06) 70%, rgba(255,255,255,0.02) 100%),
    linear-gradient(135deg,
      color-mix(in oklab, var(--ib-primary) 78%, transparent),
      color-mix(in oklab, var(--ib-primary-2) 70%, transparent)
    );
  border-color: color-mix(in oklab, var(--ib-primary) 45%, var(--ib-border));
  box-shadow:
    0 12px 26px color-mix(in oklab, var(--ib-primary) 30%, transparent),
    inset 0 1px 0 rgba(255,255,255,0.35);
}

.ib-bottom-link--center.is-active .material-symbols-rounded {
  color: white;
}

/* Menu aberto (offcanvas) também fica aceso */
.ib-bottom-link.is-menu-open {
  color: var(--ib-text);
  background: var(--ib-surface-2);
}

.ib-bottom-badge {
  position: absolute;
  top: 6px;
  right: 10px;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--ib-danger);
  color: white;
  font-size: 0.7rem;
  display: grid;
  place-items: center;
  border: 2px solid color-mix(in oklab, var(--ib-surface) 85%, transparent);
}

.table {
  color: var(--ib-text);
  --bs-table-color: var(--ib-text);
  --bs-table-bg: transparent;
  --bs-table-border-color: var(--ib-border);
}

html[data-theme="dark"] .table {
  --bs-table-striped-bg: color-mix(in oklab, var(--ib-surface-2) 72%, transparent);
  --bs-table-hover-bg: var(--ib-surface-2);
  --bs-table-active-bg: var(--ib-surface-2);
}

.table thead th {
  color: var(--ib-muted);
  font-weight: 600;
}

.form-control, .form-select {
  background: var(--ib-surface);
  color: var(--ib-text);
  border: 1px solid var(--ib-border);
}

.form-control:focus, .form-select:focus {
  border-color: var(--ib-primary);
  box-shadow: 0 0 0 .2rem rgba(37, 99, 235, 0.15);
}

html[data-theme="dark"] .form-control:focus, html[data-theme="dark"] .form-select:focus {
  box-shadow: 0 0 0 .2rem rgba(189, 147, 249, 0.22);
}

/* ===== Bootstrap overrides para dark theme ===== */
html[data-theme="dark"] .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}

html[data-theme="dark"] .badge {
  background: var(--ib-surface-2);
  color: var(--ib-text);
}

html[data-theme="dark"] hr {
  border-color: var(--ib-border);
  opacity: 1;
}

html[data-theme="dark"] .card {
  background: var(--ib-surface);
  border-color: var(--ib-border);
  color: var(--ib-text);
}

html[data-theme="dark"] .text-secondary,
html[data-theme="dark"] .text-muted {
  color: var(--ib-muted) !important;
}

html[data-theme="dark"] .alert {
  background: var(--ib-surface-2);
  border-color: var(--ib-border);
  color: var(--ib-text);
}

html[data-theme="dark"] .modal-content {
  background: var(--ib-surface);
  color: var(--ib-text);
}

html[data-theme="dark"] .modal-header {
  border-bottom-color: var(--ib-border);
}

html[data-theme="dark"] .modal-footer {
  border-top-color: var(--ib-border);
}

html[data-theme="dark"] a {
  color: color-mix(in oklab, var(--ib-primary) 70%, var(--ib-text));
}

html[data-theme="dark"] a:hover {
  color: var(--ib-primary);
}

/* Badges Bootstrap (text-bg-*) ficam muito saturadas no dark */
html[data-theme="dark"] .badge.text-bg-primary,
html[data-theme="dark"] .badge.text-bg-info,
html[data-theme="dark"] .badge.text-bg-success,
html[data-theme="dark"] .badge.text-bg-warning,
html[data-theme="dark"] .badge.text-bg-danger,
html[data-theme="dark"] .badge.text-bg-secondary {
  color: var(--ib-text) !important;
  border: 1px solid var(--ib-border);
}

html[data-theme="dark"] .badge.text-bg-primary {
  background-color: color-mix(in oklab, var(--bs-primary) 24%, var(--ib-surface-2)) !important;
}

html[data-theme="dark"] .badge.text-bg-info {
  background-color: color-mix(in oklab, var(--bs-info) 20%, var(--ib-surface-2)) !important;
}

html[data-theme="dark"] .badge.text-bg-success {
  background-color: color-mix(in oklab, var(--bs-success) 20%, var(--ib-surface-2)) !important;
}

html[data-theme="dark"] .badge.text-bg-warning {
  background-color: color-mix(in oklab, var(--bs-warning) 18%, var(--ib-surface-2)) !important;
}

html[data-theme="dark"] .badge.text-bg-danger {
  background-color: color-mix(in oklab, var(--bs-danger) 20%, var(--ib-surface-2)) !important;
}

html[data-theme="dark"] .badge.text-bg-secondary {
  background-color: color-mix(in oklab, var(--bs-secondary) 16%, var(--ib-surface-2)) !important;
}

/* Botões outline em tabelas (admin) */
html[data-theme="dark"] .btn-outline-danger,
html[data-theme="dark"] .btn-outline-success,
html[data-theme="dark"] .btn-outline-primary,
html[data-theme="dark"] .btn-outline-secondary {
  border-color: var(--ib-border);
  color: var(--ib-text);
}

html[data-theme="dark"] .btn-outline-danger:hover,
html[data-theme="dark"] .btn-outline-success:hover,
html[data-theme="dark"] .btn-outline-primary:hover,
html[data-theme="dark"] .btn-outline-secondary:hover {
  background: var(--ib-surface-2);
  color: var(--ib-text);
}

/* ===== Primeiro acesso (termos) ===== */
.ib-first-card {
  background: color-mix(in oklab, var(--ib-surface) 78%, transparent);
  border: 1px solid var(--ib-border);
  border-radius: 22px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08), 0 2px 8px rgba(15, 23, 42, 0.05);
  backdrop-filter: blur(14px);
  overflow: hidden;
}

.ib-first-head {
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--ib-border);
  background: linear-gradient(135deg,
    color-mix(in oklab, var(--ib-primary) 10%, transparent),
    color-mix(in oklab, var(--ib-surface) 90%, transparent)
  );
}

.ib-first-body {
  padding: 18px;
}

.ib-stepper {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.ib-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid var(--ib-border);
  background: color-mix(in oklab, var(--ib-surface) 84%, transparent);
}

.ib-step-dot {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: var(--ib-muted);
  background: var(--ib-surface-2);
  border: 1px solid var(--ib-border);
}

.ib-step-label {
  font-weight: 700;
  color: var(--ib-muted);
}

.ib-step.is-active {
  border-color: color-mix(in oklab, var(--ib-primary) 40%, var(--ib-border));
  background: linear-gradient(135deg,
    color-mix(in oklab, var(--ib-primary) 14%, var(--ib-surface)),
    color-mix(in oklab, var(--ib-primary-2) 10%, var(--ib-surface))
  );
}

.ib-step.is-active .ib-step-dot {
  color: white;
  border-color: color-mix(in oklab, var(--ib-primary) 40%, transparent);
  background: linear-gradient(135deg, var(--ib-primary), var(--ib-primary-2));
  box-shadow: 0 10px 22px color-mix(in oklab, var(--ib-primary) 22%, transparent);
}

.ib-step.is-active .ib-step-label {
  color: var(--ib-text);
}

.ib-panel {
  background: var(--ib-surface);
  border: 1px solid var(--ib-border);
  border-radius: 18px;
  overflow: hidden;
}

.ib-panel-head {
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--ib-border);
  background: color-mix(in oklab, var(--ib-surface-2) 70%, transparent);
}

.ib-panel-body {
  padding: 14px;
}

.ib-pill {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ib-primary);
  background: color-mix(in oklab, var(--ib-primary) 10%, var(--ib-surface));
  border: 1px solid color-mix(in oklab, var(--ib-primary) 25%, var(--ib-border));
}

.ib-section-title {
  font-weight: 800;
  color: var(--ib-text);
  margin-bottom: 10px;
}

.ib-list {
  list-style: none;
  padding-left: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.ib-list li {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  align-items: start;
  color: var(--ib-text);
}

.ib-list .material-symbols-rounded {
  font-size: 20px;
  line-height: 1;
  color: color-mix(in oklab, var(--ib-primary) 70%, var(--ib-muted));
  margin-top: 1px;
}

.ib-terms-scroll {
  max-height: min(56vh, 560px);
  overflow: auto;
  padding-right: 6px;
}

.ib-note {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  align-items: start;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--ib-border);
  background: color-mix(in oklab, var(--ib-surface-2) 72%, transparent);
  color: var(--ib-muted);
  font-size: 0.92rem;
}

.ib-note .material-symbols-rounded {
  font-size: 20px;
  line-height: 1;
}

.ib-note--success {
  color: color-mix(in oklab, var(--ib-primary) 85%, var(--ib-text));
  background: color-mix(in oklab, var(--ib-primary) 10%, var(--ib-surface));
  border-color: color-mix(in oklab, var(--ib-primary) 22%, var(--ib-border));
}

.ib-check {
  display: flex;
  gap: 10px;
}

.ib-check .form-check-input {
  margin-top: 0.2rem;
}

@media (min-width: 992px) {
  .ib-side-panel {
    position: sticky;
    top: calc(var(--ib-topbar-h) + 16px);
  }
}

@media (max-width: 575.98px) {
  .ib-first-head {
    padding: 16px;
  }
  .ib-first-body {
    padding: 16px;
  }
  .ib-terms-scroll {
    max-height: 48vh;
  }
}

.ib-sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.10);
  padding-top: 12px;
  color: var(--ib-sidebar-muted);
}

@media (max-width: 991.98px) {
  .ib-content {
    /* Espaço generoso para garantir que o contéudo (principalmente botões de formulário) não fique sob a navbar */
    padding-bottom: calc(var(--ib-bottom-nav-h) + 80px + env(safe-area-inset-bottom)) !important;
  }
}

/* ===== Sidebar recolhida (desktop) ===== */
@media (min-width: 992px) {
  body.ib-sidebar-collapsed .ib-sidebar {
    width: 86px;
    min-width: 86px;
    overflow: visible;
    z-index: 40;
  }

  body.ib-sidebar-collapsed .ib-sidebar nav {
    overflow: visible;
  }

  body.ib-sidebar-collapsed .ib-nav-chevron {
    display: none;
  }

  body.ib-sidebar-collapsed .ib-nav-flyout {
    position: relative;
  }

  body.ib-sidebar-collapsed .ib-nav-flyout > .ib-nav-sub {
    display: none !important;
    position: absolute;
    left: calc(100% + 6px);
    top: 0;
    z-index: 1300;
    min-width: 240px;
    margin: 0;
    padding: 8px !important;
    border-radius: 12px;
    background: var(--ib-sidebar-bg);
    border: 1px solid color-mix(in oklab, var(--ib-sidebar-text) 16%, transparent);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
  }

  body.ib-sidebar-collapsed .ib-nav-flyout > .ib-nav-sub::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 0;
    width: 12px;
    height: 100%;
  }

  body.ib-sidebar-collapsed .ib-nav-flyout:hover > .ib-nav-sub,
  body.ib-sidebar-collapsed .ib-nav-flyout:focus-within > .ib-nav-sub {
    display: block !important;
  }

  body.ib-sidebar-collapsed .ib-nav-flyout > .ib-nav-sub .ib-nav-sublink {
    white-space: nowrap;
    padding: 8px 10px;
  }

  body.ib-sidebar-collapsed .ib-brand-text,
  body.ib-sidebar-collapsed .ib-nav-section {
    display: none;
  }

  body.ib-sidebar-collapsed .ib-nav-link {
    justify-content: center;
    gap: 0;
    padding: 12px 10px;
  }

  body.ib-sidebar-collapsed .ib-nav-text {
    display: none;
  }

  body.ib-sidebar-collapsed .ib-nav-link i {
    font-size: 1.25rem;
  }

  body.ib-sidebar-collapsed .ib-sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.10);
  }

  body.ib-sidebar-collapsed .ib-sidebar-footer .small,
  body.ib-sidebar-collapsed .ib-sidebar-footer button {
    display: none;
  }
}

/* ===== Configurações: seletor de tema ===== */
.ib-theme-card {
  width: 100%;
  background: var(--ib-surface);
  border: 2px solid var(--ib-border);
  border-radius: 16px;
  padding: 0;
  cursor: pointer;
  transition: all 180ms ease;
  position: relative;
  overflow: hidden;
}

.ib-theme-card:hover {
  border-color: var(--ib-primary);
  transform: translateY(-2px);
  box-shadow: var(--ib-shadow-soft);
}

.ib-theme-card--active {
  border-color: var(--ib-primary);
  background: color-mix(in oklab, var(--ib-primary) 5%, var(--ib-surface));
}

.ib-theme-preview {
  aspect-ratio: 16/10;
  border-radius: 14px 14px 0 0;
  overflow: hidden;
  position: relative;
}

.ib-theme-preview--light {
  background: #f6f8fb;
}

.ib-theme-preview--dark {
  background: #0f0f17;
}

.ib-theme-preview-header {
  height: 18%;
  background: rgba(255, 255, 255, 0.65);
  border-bottom: 1px solid rgba(15, 23, 42, 0.12);
}

.ib-theme-preview--dark .ib-theme-preview-header {
  background: rgba(27, 27, 39, 0.85);
  border-bottom-color: rgba(248, 248, 242, 0.14);
}

.ib-theme-preview-body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ib-theme-preview-card {
  height: 20px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 8px;
  border: 1px solid rgba(15, 23, 42, 0.10);
}

.ib-theme-preview--dark .ib-theme-preview-card {
  background: rgba(27, 27, 39, 0.95);
  border-color: rgba(248, 248, 242, 0.12);
}

.ib-theme-card-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 16px;
  color: var(--ib-text);
}

.ib-theme-card-check {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--ib-primary);
  color: white;
  display: grid;
  place-items: center;
  opacity: 0;
  transform: scale(0.6);
  transition: all 180ms ease;
}

.ib-theme-card-check .material-symbols-rounded {
  font-size: 18px;
  font-variation-settings: 'FILL' 1, 'wght' 600, 'GRAD' 0, 'opsz' 20;
}

.ib-theme-card--active .ib-theme-card-check {
  opacity: 1;
  transform: scale(1);
}

/* ===== Admin: Usuários ===== */
/* Header */
.ib-users-header {
  margin-bottom: 2rem;
}

.ib-page-heading {
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ib-text);
  margin: 0;
}

.ib-page-description {
  font-size: 0.9rem;
  color: var(--ib-muted);
  font-weight: 400;
  line-height: 1.5;
}

/* View Switcher */
.ib-view-switcher {
  border: 1px solid var(--ib-border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--ib-surface);
}

.ib-btn-view {
  background: transparent;
  border: none;
  color: var(--ib-muted);
  padding: 6px 12px;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 140ms ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ib-btn-view:hover {
  background: var(--ib-surface-2);
  color: var(--ib-text);
}

.ib-users-view-btn--active {
  background: var(--ib-primary);
  color: white;
}

.ib-users-view-btn--active:hover {
  background: var(--ib-primary-2);
  color: white;
}

/* View Container */
.ib-users-view {
  display: none;
}

.ib-users-view--active {
  display: block;
  animation: ib-fade-up 180ms ease;
}

/* User Card */
.ib-user-card {
  background: var(--ib-surface);
  border: 1px solid var(--ib-border);
  border-radius: 12px;
  padding: 20px;
  transition: all 180ms ease;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ib-user-card:hover {
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
  border-color: color-mix(in oklab, var(--ib-border) 70%, var(--ib-primary));
  transform: translateY(-2px);
}

.ib-user-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.ib-user-info {
  min-width: 0;
  flex: 1;
}

.ib-user-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ib-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
  letter-spacing: -0.01em;
}

.ib-user-email {
  font-size: 0.8125rem;
  color: var(--ib-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.ib-user-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--ib-border);
}

.ib-user-badges {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ib-user-id {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ib-muted);
  letter-spacing: 0.02em;
}

/* Table Design */
.ib-table-container {
  background: var(--ib-surface);
  border: 1px solid var(--ib-border);
  border-radius: 12px;
  overflow: hidden;
}

.ib-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
}

.ib-table thead {
  background: var(--ib-surface-2);
  border-bottom: 1px solid var(--ib-border);
}

.ib-table th {
  text-align: left;
  padding: 14px 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ib-muted);
  white-space: nowrap;
}

.ib-table-row {
  border-bottom: 1px solid var(--ib-border);
  transition: background 120ms ease;
}

.ib-table-row:last-child {
  border-bottom: none;
}

.ib-table-row:hover {
  background: var(--ib-surface-2);
}

.ib-table td {
  padding: 16px 20px;
  vertical-align: middle;
}

.ib-table-cell-id {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ib-muted);
  width: 60px;
}

.ib-table-cell-name {
  font-weight: 600;
  color: var(--ib-text);
  letter-spacing: -0.01em;
}

.ib-table-cell-email {
  color: var(--ib-muted);
  font-size: 0.8125rem;
}

.ib-table-cell-role {
  width: 100px;
}

.ib-table-cell-status {
  width: 100px;
}

.ib-table-cell-actions {
  width: 60px;
  text-align: right;
}

/* Badges */
.ib-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1;
  white-space: nowrap;
}

.ib-badge-role {
  border: 1px solid;
}

.ib-badge-admin {
  background: color-mix(in oklab, var(--ib-primary) 8%, transparent);
  color: var(--ib-primary);
  border-color: color-mix(in oklab, var(--ib-primary) 20%, transparent);
}

.ib-badge-user {
  background: color-mix(in oklab, var(--ib-text) 4%, transparent);
  color: var(--ib-muted);
  border-color: var(--ib-border);
}

.ib-badge-status {
  border: 1px solid;
}

.ib-badge-active {
  background: color-mix(in oklab, #10b981 6%, transparent);
  color: #059669;
  border-color: color-mix(in oklab, #10b981 20%, transparent);
}

.ib-badge-inactive {
  background: color-mix(in oklab, var(--ib-danger) 6%, transparent);
  color: var(--ib-danger);
  border-color: color-mix(in oklab, var(--ib-danger) 20%, transparent);
}

/* Action Menu */
.ib-action-menu {
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ib-muted);
  cursor: pointer;
  transition: all 140ms ease;
}

.ib-action-menu:hover {
  background: var(--ib-surface-2);
  color: var(--ib-text);
}

.ib-action-menu .material-symbols-rounded {
  font-size: 20px;
  font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 20;
}

.ib-actions-menu {
  min-width: 200px;
  padding: 8px;
  border: 1px solid var(--ib-border);
  border-radius: 12px;
  background: var(--ib-surface);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.ib-actions-menu .dropdown-item {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ib-text);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 120ms ease;
}

.ib-actions-menu .dropdown-item:hover {
  background: var(--ib-surface-2);
}

.ib-actions-menu .dropdown-item .material-symbols-rounded {
  font-size: 18px;
  color: var(--ib-muted);
}

.ib-action-delete {
  color: var(--ib-danger) !important;
}

.ib-action-delete:hover {
  background: color-mix(in oklab, var(--ib-danger) 8%, transparent) !important;
}

.ib-action-delete .material-symbols-rounded {
  color: var(--ib-danger) !important;
}

.ib-actions-menu .dropdown-divider {
  margin: 8px 0;
  border-color: var(--ib-border);
}

/* Empty State */
.ib-empty-state {
  text-align: center;
  padding: 80px 20px;
  background: var(--ib-surface);
  border: 1px solid var(--ib-border);
  border-radius: 12px;
}

.ib-empty-icon {
  font-size: 64px;
  color: var(--ib-muted);
  opacity: 0.3;
  display: block;
  margin-bottom: 16px;
}

.ib-empty-message {
  font-size: 0.9375rem;
  color: var(--ib-muted);
  margin-bottom: 24px;
}

@keyframes ib-fade-up {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 575.98px) {
  .ib-page-heading {
    font-size: 1.5rem;
  }
  
  .ib-table th,
  .ib-table td {
    padding: 12px 16px;
  }
  
  .ib-user-card {
    padding: 16px;
  }
}

/* ===== Forms ===== */
.ib-form-card {
  background: var(--ib-surface);
  border: 1px solid var(--ib-border);
  border-radius: 12px;
  padding: 0;
  overflow: hidden;
}

.ib-form-header {
  padding: 24px 28px;
  border-bottom: 1px solid var(--ib-border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  background: var(--ib-surface-2);
}

.ib-form-title {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ib-text);
  margin: 0;
  line-height: 1.3;
}

.ib-form-description {
  font-size: 0.875rem;
  color: var(--ib-muted);
  margin: 4px 0 0;
  line-height: 1.5;
}

.ib-form {
  padding: 28px;
}

.ib-form-section {
  margin-bottom: 28px;
}

.ib-form-section:last-of-type {
  margin-bottom: 0;
}

.ib-form-group {
  margin-bottom: 20px;
}

.ib-form-group:last-child {
  margin-bottom: 0;
}

.ib-form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ib-text);
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.ib-input,
.ib-select {
  width: 100%;
  padding: 11px 14px;
  font-size: 0.9375rem;
  font-family: var(--ib-font-sans);
  color: var(--ib-text);
  background: var(--ib-surface);
  border: 1px solid var(--ib-border);
  border-radius: 8px;
  transition: all 160ms ease;
  outline: none;
}

.ib-input:focus,
.ib-select:focus {
  border-color: var(--ib-primary);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ib-primary) 10%, transparent);
}

.ib-input::placeholder {
  color: var(--ib-muted);
  opacity: 0.6;
}

.ib-form-hint {
  font-size: 0.75rem;
  color: var(--ib-muted);
  margin-top: 6px;
  line-height: 1.4;
}

.ib-form-actions {
  padding-top: 24px;
  border-top: 1px solid var(--ib-border);
  margin-top: 28px;
}

.ib-btn-block {
  width: 100%;
  justify-content: center;
}

/* Danger Zone */
.ib-danger-zone {
  margin-top: 24px;
  background: color-mix(in oklab, var(--ib-danger) 3%, var(--ib-surface));
  border: 1px solid color-mix(in oklab, var(--ib-danger) 20%, transparent);
  border-radius: 12px;
  padding: 20px 24px;
}

.ib-danger-zone-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.ib-danger-icon {
  font-size: 24px;
  color: var(--ib-danger);
  flex-shrink: 0;
  margin-top: 2px;
}

.ib-danger-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--ib-danger);
  margin-bottom: 2px;
}

.ib-danger-description {
  font-size: 0.8125rem;
  color: var(--ib-muted);
  line-height: 1.4;
}

@media (max-width: 575.98px) {
  .ib-form-header {
    padding: 20px;
  }
  
  .ib-form {
    padding: 20px;
  }
  
  .ib-form-title {
    font-size: 1.25rem;
  }
}

@media (max-width: 575.98px) {
  .ib-theme-card-label {
    font-size: 0.95rem;
  }
}

/* ===========================
   Autocomplete
   =========================== */
.ib-autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: color-mix(in oklab, var(--ib-surface) 92%, transparent);
  border: 1px solid var(--ib-border);
  border-radius: 14px;
  max-height: 300px;
  overflow-y: auto;
  z-index: 2000;
  isolation: isolate;
  box-shadow: var(--ib-shadow);
  backdrop-filter: blur(10px);
  display: none;
  margin-top: 6px;
}

.ib-autocomplete-dropdown--show {
  display: block;
}

.position-relative {
  position: relative !important;
}

.ib-autocomplete-item {
  padding: 0.75rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--ib-border);
  transition: background-color 0.15s ease;
}

.ib-autocomplete-item:last-child {
  border-bottom: none;
}

.ib-autocomplete-item:hover {
  background-color: var(--ib-surface-2);
}

.ib-autocomplete-name {
  font-weight: 600;
  color: var(--ib-text);
  margin-bottom: 0.25rem;
}

.ib-autocomplete-email {
  font-size: 0.875rem;
  color: var(--ib-muted);
}

.ib-autocomplete-empty {
  padding: 1rem;
  text-align: center;
  color: var(--ib-muted);
  font-size: 0.875rem;
}

/* ===========================
   Loan Total Display
   =========================== */
.ib-loan-total {
  padding: 1rem;
  background: linear-gradient(135deg, var(--ib-primary) 0%, var(--ib-primary-dark) 100%);
  color: white;
  font-size: 1.5rem;
  font-weight: 700;
  border-radius: 0.5rem;
  text-align: center;
  box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
}

.ib-loan-total-compact {
  padding: 0.5rem 0.75rem;
  background: linear-gradient(135deg, var(--ib-primary) 0%, var(--ib-primary-dark) 100%);
  color: white;
  font-size: 1.125rem;
  font-weight: 600;
  border-radius: 0.375rem;
  text-align: center;
}

/* ===========================
   Installments
   =========================== */
.ib-installment-row {
  padding: 0.75rem;
  background: var(--ib-card-bg);
  border: 1px solid var(--ib-border-color);
  border-radius: 0.375rem;
  margin-bottom: 0.5rem;
  transition: all 0.2s ease;
}

.ib-installment-row:hover {
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.ib-installment-date-row {
  padding: 0.5rem;
  background: var(--ib-hover-bg);
  border-radius: 0.25rem;
}

/* ===== Loans (Empréstimos) ===== */
.ib-loans-view {
  display: none;
}

.ib-loans-view--active {
  display: block;
}

.ib-loan-card {
  background: var(--ib-surface);
  border: 1px solid var(--ib-border);
  border-radius: 14px;
  padding: 0;
  overflow: hidden;
  transition: all 160ms ease;
  box-shadow: var(--ib-shadow-soft);
  height: 100%;
  display: flex;
  flex-direction: column;
}

.ib-loan-card:hover {
  border-color: color-mix(in oklab, var(--ib-primary) 30%, var(--ib-border));
  box-shadow: var(--ib-shadow);
  transform: translateY(-2px);
}

.ib-loan-card-header {
  padding: 16px;
  border-bottom: 1px solid var(--ib-border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  background: var(--ib-surface-2);
}

.ib-loan-info {
  min-width: 0;
  flex: 1;
}

.ib-loan-id {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ib-muted);
  margin-bottom: 4px;
}

.ib-loan-user {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ib-text);
  letter-spacing: -0.01em;
  margin-bottom: 2px;
}

.ib-loan-email {
  font-size: 0.8rem;
  color: var(--ib-muted);
}

.ib-loan-card-body {
  padding: 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ib-loan-group {
  margin-bottom: 1.25rem;
}

.ib-loan-group-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--ib-border);
  border-radius: 12px;
  background: color-mix(in oklab, var(--ib-surface-2) 85%, var(--ib-surface));
}

.ib-loan-group-name {
  font-weight: 800;
  color: var(--ib-text);
}

.ib-loan-group-email {
  font-size: 0.8rem;
  color: var(--ib-muted);
}

.ib-loan-group-meta {
  display: flex;
  gap: 0.85rem;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--ib-muted);
  font-weight: 600;
}

.ib-loan-group-row td {
  background: color-mix(in oklab, var(--ib-surface-2) 90%, var(--ib-surface));
  font-size: 0.85rem;
  padding-top: 10px;
  padding-bottom: 10px;
}

.ib-loan-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: auto;
  padding-top: 0.35rem;
}

.ib-loan-actions form {
  margin: 0;
}

.ib-loan-actions--table {
  justify-content: flex-end;
}

.ib-loan-metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.ib-loan-metric {
  background: var(--ib-surface-2);
  border: 1px solid var(--ib-border);
  border-radius: 10px;
  padding: 10px 12px;
}

.ib-loan-metric-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ib-muted);
  margin-bottom: 4px;
}

.ib-loan-metric-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ib-text);
  letter-spacing: -0.02em;
}

.ib-loan-dates {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.ib-loan-date {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--ib-muted);
}

.ib-loan-amount {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ib-text);
}

.ib-badge-loan-active {
  background: color-mix(in oklab, #16a34a 12%, var(--ib-surface));
  color: #16a34a;
  border-color: color-mix(in oklab, #16a34a 25%, var(--ib-border));
}

.ib-badge-loan-closed {
  background: color-mix(in oklab, var(--ib-muted) 8%, var(--ib-surface));
  color: var(--ib-muted);
  border-color: color-mix(in oklab, var(--ib-muted) 20%, var(--ib-border));
}

.ib-badge-loan-defaulted {
  background: color-mix(in oklab, var(--ib-danger) 12%, var(--ib-surface));
  color: var(--ib-danger);
  border-color: color-mix(in oklab, var(--ib-danger) 25%, var(--ib-border));
}

/* Modal modernizado */
.ib-modal {
  background: var(--ib-surface);
  border: 1px solid var(--ib-border);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.15);
}

.ib-modal .modal-header {
  border-bottom-color: var(--ib-border);
  padding: 20px 24px;
}

.ib-modal .modal-title {
  font-weight: 700;
  color: var(--ib-text);
}

.ib-modal .modal-body {
  padding: 20px 24px;
}

.ib-modal .modal-footer {
  border-top-color: var(--ib-border);
  padding: 16px 24px;
}

html[data-theme="dark"] .ib-modal {
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
