/* ==========================================================================
   Funilera redesign — "01b Refined Classic" shared theme.
   Design tokens + chrome/component styles reused across redesigned screens.
   Loaded alongside Tailwind (JS-rendered markup still uses Tailwind classes).
   ========================================================================== */

:root {
  --ink:       oklch(0.22 0.01 60);
  --ink-2:     oklch(0.38 0.01 60);
  --ink-3:     oklch(0.55 0.01 60);
  --ink-4:     oklch(0.72 0.008 60);
  --line:      oklch(0.90 0.002 60);
  --line-2:    oklch(0.94 0.002 60);
  --bg:        oklch(0.985 0.001 60);
  --bg-2:      oklch(0.965 0.001 60);
  --bg-3:      oklch(0.945 0.002 60);
  --card:      #ffffff;

  --brand:     oklch(0.66 0.10 180);
  --brand-ink: oklch(0.38 0.09 180);
  --brand-2:   oklch(0.92 0.05 180);
  --brand-3:   oklch(0.97 0.02 180);

  --warn:      oklch(0.78 0.14 75);
  --ok:        oklch(0.70 0.13 155);
  --bad:       oklch(0.62 0.17 25);

  --radius:    10px;
  --radius-sm: 6px;

  --rd-sans:  "Inter", ui-sans-serif, system-ui, sans-serif;
  --rd-serif: "Instrument Serif", Georgia, serif;
  --rd-mono:  "JetBrains Mono", ui-monospace, monospace;
}

/* Shared filter-column width (sidebar.css sets 25rem; 336px ≈ 280px + 20%). */
@media (min-width: 768px) {
  :root { --sidebar-width-expanded: 336px; }
}

/* --------------------------------------------------------------------------
   Shell
   -------------------------------------------------------------------------- */
body.rd-shell {
  margin: 0;
  background: #efece6;
  font-family: var(--rd-sans);
  color: var(--ink);
}
.rd-shell * { box-sizing: border-box; }

.rd-body {
  display: flex;
  min-height: calc(100vh - 3.5rem);
}
.rd-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-2);
}

.rd-mono { font-family: var(--rd-mono); }
.rd-serif { font-family: var(--rd-serif); }

/* --------------------------------------------------------------------------
   Beta bar
   -------------------------------------------------------------------------- */
.rd-beta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 6px 16px;
  font-size: 12px;
  color: #8a6f1a;
  background: #fdf7e3;
  border-bottom: 1px solid #f0e7b8;
}
.rd-beta a { color: #8a6f1a; font-weight: 600; }

/* --------------------------------------------------------------------------
   Top navbar
   -------------------------------------------------------------------------- */
.rd-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  height: 3.5rem;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 40;
}
.rd-brand {
  display: flex;
  align-items: center;
  gap: 3px;
  text-decoration: none;
}
.rd-brand-mark {
  width: 20px; height: 20px; object-fit: contain; display: block;
  box-sizing: content-box;      /* override the shell's border-box so padding adds space, not shrink */
  padding-bottom: 2px;          /* vertical position knob: increase to raise the icon, decrease/0 to lower it */
}
.rd-brand-name {
  font-family: "Bungee", var(--rd-sans);
  font-weight: 400;
  font-size: 18px;
  line-height: 1;
  color: var(--ink);
}
.rd-nav {
  display: flex;
  gap: 2px;
}
.rd-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
}
.rd-nav-btn:hover { background: var(--bg-3); }
.rd-nav-btn.is-active { background: var(--bg-3); color: var(--ink); }
.rd-nav-btn.is-disabled {
  color: var(--ink-4);
  cursor: not-allowed;
  pointer-events: none;
}
.rd-nav-soon {
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-4);
}
.rd-topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.rd-plan-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink-2);
  text-decoration: none;
}
.rd-plan-chip.is-paid { border-color: var(--brand-2); background: var(--brand-3); color: var(--brand-ink); }
.rd-plan-dot { width: 6px; height: 6px; border-radius: 3px; background: var(--warn); }
.rd-plan-chip.is-paid .rd-plan-dot { background: var(--brand); }
.rd-icon-btn {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  background: transparent; border: none; border-radius: 6px;
  color: var(--ink-2); cursor: pointer; flex-shrink: 0;
}
.rd-icon-btn:hover { background: var(--bg-3); }
.rd-divider { width: 1px; height: 22px; background: var(--line); }
.rd-user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
}
.rd-avatar {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--brand-2); color: var(--brand-ink);
  font-size: 10px; font-weight: 700;
  display: grid; place-items: center;
  object-fit: cover;
  overflow: hidden;
}
.rd-menu-wrap { position: relative; }
.rd-menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  min-width: 180px;
  background: #fff; border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 12px 32px rgba(0,0,0,.14);
  padding: 4px; z-index: 60;
  opacity: 0; visibility: hidden; transition: opacity .12s, visibility .12s;
}
.rd-menu-wrap:hover .rd-menu { opacity: 1; visibility: visible; }
.rd-menu a {
  display: block; padding: 8px 10px; font-size: 13px;
  color: var(--ink-2); text-decoration: none; border-radius: 6px;
}
.rd-menu a:hover { background: var(--bg-3); color: var(--ink); }
.rd-menu-sep { height: 1px; background: var(--line-2); margin: 4px 0; }

/* --------------------------------------------------------------------------
   Filter sidebar frame (reuses core sidebar.js collapse mechanics)
   -------------------------------------------------------------------------- */
#sidebar.rd-filtercol {
  border-right: 1px solid var(--line);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  transition: width .15s ease;
}
.rd-filter-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line-2);
}
.rd-filter-eyebrow {
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 600;
}
.rd-filter-title { font-size: 15px; font-weight: 600; margin-top: 2px; color: var(--ink); }
#sidebar.sidebar-collapsed .rd-filter-header { justify-content: center; padding: 14px 8px; }
#sidebar-page-content { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#sidebar.sidebar-collapsed .rd-filter-headings,
#sidebar.sidebar-collapsed #btn-limpar-filtros,
#sidebar.sidebar-collapsed .rd-preset-row,
#sidebar.sidebar-collapsed .rd-filter-footer,
#sidebar.sidebar-collapsed #sidebar-content { display: none; }

.rd-preset-row {
  display: flex; gap: 6px;
  padding: 10px 12px 4px;
}
.rd-preset-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 10px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--ink-2); cursor: pointer;
}
.rd-preset-btn:hover { background: var(--bg-3); }
.rd-preset-btn.rd-preset-grow { flex: 1; justify-content: space-between; }

/* Saved-searches dropdown + save popover */
.rd-ss-panel {
  position: absolute; top: calc(100% + 4px); z-index: 40;
  width: 244px; max-width: calc(100% - 24px);
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-sm); box-shadow: 0 8px 24px rgba(0,0,0,.12);
  padding: 6px;
}
#saved-searches-panel { left: 12px; }
.rd-ss-panel-right { right: 12px; left: auto; padding: 12px; }
.rd-ss-list { max-height: 264px; overflow: auto; display: flex; flex-direction: column; }
.rd-ss-item { display: flex; align-items: center; gap: 6px; padding: 7px 8px; border-radius: var(--radius-sm); }
.rd-ss-item:hover { background: var(--bg-3); }
.rd-ss-item-load { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; background: none; border: none; text-align: left; cursor: pointer; padding: 0; }
.rd-ss-item-name { font-size: 13px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rd-ss-item-date { font-size: 11px; color: var(--ink-4); }
.rd-ss-item-del { flex-shrink: 0; border: none; background: none; color: var(--ink-4); cursor: pointer; padding: 3px; line-height: 0; border-radius: 4px; }
.rd-ss-item-del:hover { color: var(--bad); background: var(--bg); }
.rd-ss-empty { padding: 14px 8px; font-size: 12.5px; color: var(--ink-3); text-align: center; }
.rd-ss-label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.rd-ss-input { width: 100%; padding: 8px 10px; font-size: 13px; font-family: var(--rd-sans); color: var(--ink); border: 1.5px solid var(--line); border-radius: var(--radius-sm); outline: none; box-sizing: border-box; }
.rd-ss-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-3); }
.rd-ss-error { font-size: 12px; color: var(--bad); margin-top: 6px; }
.rd-ss-actions { display: flex; gap: 8px; margin-top: 12px; }
.rd-ss-btn-ghost, .rd-ss-btn-primary { flex: 1; padding: 7px 10px; font-size: 13px; font-weight: 600; border-radius: var(--radius-sm); cursor: pointer; border: 1px solid transparent; font-family: var(--rd-sans); }
.rd-ss-btn-ghost { background: var(--bg); border-color: var(--line); color: var(--ink-2); }
.rd-ss-btn-ghost:hover { background: var(--bg-3); }
.rd-ss-btn-primary { background: var(--brand); color: #fff; }
.rd-ss-btn-primary:hover { filter: brightness(.96); }
.rd-ss-btn-primary:disabled { opacity: .6; cursor: default; }

.rd-filter-scroll { flex: 1; overflow: auto; padding: 8px 12px 12px; }
.rd-filter-footer { padding: 10px 16px 14px; border-top: 1px solid var(--line-2); }
.rd-btn-buscar {
  width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 16px; font-size: 14px; font-weight: 600;
  background: var(--brand); color: #fff; border: none;
  border-radius: 7px; cursor: pointer;
}
.rd-btn-buscar:hover { filter: brightness(0.96); }

/* --------------------------------------------------------------------------
   Main column: search bar, insight banner, results header
   -------------------------------------------------------------------------- */
.rd-searchwrap {
  padding: 18px 22px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.rd-searchbar {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 6px 6px 14px;
  border: 1.5px solid var(--line); border-radius: var(--radius);
  background: #fff;
}
.rd-searchbar:focus-within { border-color: var(--brand); }
.rd-searchbar input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 14px; font-family: var(--rd-sans); color: var(--ink);
  padding: 7px 0;
}
.rd-btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; font-size: 13px; font-weight: 600;
  background: var(--brand); color: #fff; border: none;
  border-radius: 7px; cursor: pointer;
}
.rd-btn-primary:hover { filter: brightness(0.96); }
.rd-btn-outline {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; font-size: 13px; font-weight: 600;
  background: #fff; color: var(--brand-ink);
  border: 1.5px solid var(--brand); border-radius: 7px; cursor: pointer;
}
.rd-btn-outline:hover { background: var(--brand-3); }
.rd-btn-icon {
  width: 34px; height: 34px; display: grid; place-items: center;
  background: #fff; border: 1px solid var(--line); border-radius: 7px;
  color: var(--ink-2); cursor: pointer; flex-shrink: 0;
}
.rd-btn-icon:hover { background: var(--bg-3); }
/* Results toolbar: keep outline buttons neutral so only Enriquecer reads green. */
.rd-results-head .rd-btn-outline { color: var(--ink-2); border-color: var(--line); }
.rd-results-head .rd-btn-outline:hover { background: var(--bg-3); }
.rd-btn-outline:disabled, .rd-btn-primary:disabled { opacity: .5; cursor: default; filter: none; }
/* Enabled in the DOM (so the title tooltip shows on hover) but visually and
   functionally disabled — used for "coming soon" actions. */
.rd-btn-primary[aria-disabled="true"], .rd-btn-outline[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.rd-btn-primary[aria-disabled="true"]:hover { filter: none; }
.rd-btn-outline[aria-disabled="true"]:hover { background: #fff; }

/* Immediate hover tooltip (from data-tip) — used for "coming soon" actions. */
.rd-tip { position: relative; }
.rd-tip::after {
  content: attr(data-tip);
  position: absolute; top: calc(100% + 7px); left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; font-size: 11px; font-weight: 500; line-height: 1;
  padding: 5px 8px; border-radius: 6px; white-space: nowrap;
  opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .12s; z-index: 60;
}
.rd-tip::before {
  content: ""; position: absolute; top: calc(100% + 3px); left: 50%; transform: translateX(-50%);
  border: 4px solid transparent; border-bottom-color: var(--ink);
  opacity: 0; visibility: hidden; transition: opacity .12s; z-index: 60;
}
.rd-tip:hover::after, .rd-tip:hover::before { opacity: 1; visibility: visible; }
.rd-btn-danger { color: var(--bad); border-color: #e4b6ae; background: #fff; }
.rd-btn-danger:hover { background: #fdf0ee; }
.rd-btn-danger:disabled:hover { background: #fff; }

/* Portfolio detail — breadcrumb header band (above the search bar). */
.rd-pf-crumb {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 16px 22px 12px; background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.rd-pf-back {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--brand-ink); font-size: 13px; font-weight: 600; text-decoration: none;
}
.rd-pf-back:hover { text-decoration: underline; }
.rd-pf-sep { color: var(--ink-4); }
.rd-pf-name { font-size: 18px; font-weight: 600; color: var(--ink); margin: 0; }
.rd-pf-countbadge {
  font-size: 12px; font-weight: 500; color: var(--ink-3);
  background: var(--bg-3); padding: 3px 10px; border-radius: 999px;
}

.rd-insight {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 12px 22px;
  background: var(--brand-3);
  border-bottom: 1px solid var(--brand-2);
}
.rd-insight-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: #fff; border: 1px solid var(--brand-2);
  display: grid; place-items: center; flex-shrink: 0;
  color: var(--brand-ink);
}
.rd-insight-title { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.rd-insight-sub { font-size: 12px; color: var(--ink-3); margin-top: 1px; }
.rd-insight-cta {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; font-size: 12.5px; font-weight: 600;
  background: var(--brand); color: #fff; border: none;
  border-radius: 7px; cursor: pointer; white-space: nowrap;
}
.rd-insight-cta:disabled { opacity: .7; cursor: default; }

.rd-results-count { font-family: var(--rd-mono); font-size: 15px; font-weight: 500; letter-spacing: -0.01em; color: var(--ink); }

/* Full-bleed main-column bands (matches the mockup: edge-to-edge sections
   separated by horizontal borders, each with its own 22px inner padding). */
.rd-results-scroll { flex: 1; overflow: auto; }
.rd-results-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 22px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

/* Results table — full-bleed, row dividers only (no card). */
.rd-tablewrap { background: var(--bg); }
.rd-tablewrap table { width: 100%; border-collapse: collapse; }
.rd-tablewrap thead th {
  text-transform: uppercase; font-size: 11px; letter-spacing: .04em;
  color: var(--ink-3); font-weight: 600; text-align: left;
  padding: 10px 12px; background: var(--bg-2);
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
.rd-tablewrap thead th:first-child { padding-left: 22px; }
.rd-tablewrap thead th:last-child { padding-right: 22px; }
.rd-tablewrap tbody td {
  padding: 12px 12px; border-bottom: 1px solid var(--line-2);
  vertical-align: middle; font-size: 12.5px; color: var(--ink-2);
}
.rd-tablewrap tbody td:first-child { padding-left: 22px; }
.rd-tablewrap tbody td:last-child { padding-right: 22px; }
.rd-tablewrap tbody tr:hover { background: var(--bg-2); }
/* Column-specific typography to match the mockup. */
.rd-tablewrap tbody td:nth-child(2) { font-family: var(--rd-mono); font-size: 12px; color: var(--ink); }   /* CNPJ */
.rd-tablewrap tbody td:nth-child(3) a { color: var(--brand-ink); font-weight: 500; text-decoration: none; }  /* Razão social */
.rd-tablewrap tbody td:nth-child(4) { color: var(--ink); font-weight: 600; }                                 /* Nome fantasia */
.rd-tablewrap tbody td:nth-child(7),
.rd-tablewrap tbody td:nth-child(8) { text-align: center; color: var(--ink-4); }                              /* Telefone / E-mail */
.rd-tablewrap tbody td:nth-child(7) .text-teal-600,
.rd-tablewrap tbody td:nth-child(8) .text-teal-600 { color: var(--brand-ink); }

/* Pagination band. */
.rd-pagination {
  margin: 0; padding: 10px 22px;
  border-top: 1px solid var(--line); background: var(--bg);
}

/* ------- Flat filter groups (mockup style, no bordered boxes) ------- */
#sidebar .rd-filter-scroll { padding: 4px 0 12px; }
#sidebar #filter-sidebar { }
#sidebar #filter-sidebar > * + * { margin-top: 0 !important; }
#sidebar #filter-sidebar details {
  border: none !important;
  border-bottom: 1px solid var(--line) !important;   /* section separator (was clobbered by border:none) */
  border-radius: 0 !important;
}
#sidebar #filter-sidebar summary {
  background: transparent !important; padding: 11px 16px !important;
}
#sidebar #filter-sidebar summary > span.font-medium {
  font-weight: 500; font-size: 13px; color: var(--ink);
}
#sidebar #filter-sidebar details > div { padding-left: 16px; padding-right: 16px; }
/* Count badge as a small pill instead of a 20px circle. */
#sidebar [id$="-filter-badge"] {
  width: auto !important; height: auto !important;
  min-width: 0 !important; border-radius: 999px;
  padding: 1px 6px; font-size: 10px; line-height: 1.4;
  background: var(--brand);
}

/* ==========================================================================
   Mobile (< 768px) — native-app layout matching proposal-1-mobile
   The desktop topbar/sidebar layout is swapped for: a compact header, a "Busca"
   title, a search field + a Filtros button that opens the filter column as a
   BOTTOM SHEET, applied-filter chips, the insight card, a count + actions row,
   result rows, and a fixed bottom tab bar. Functional nodes are shared with
   desktop; only presentational chrome differs.
   ========================================================================== */

/* Mobile-only chrome is hidden by default (desktop). */
.rd-topbar-m, .rd-tabbar, .rd-m-title, .rd-m-searchwrap, .rd-m-chips, .rd-m-check,
.rd-sheet-handle, .rd-sheet-title, .rd-sheet-x, .rd-sheet-clear { display: none; }

@media (max-width: 767px) {
  body.rd-shell { background: var(--bg); }
  .rd-beta { display: none; }               /* beta bar omitted on mobile (matches design) */
  .rd-topbar { display: none; }             /* desktop topbar → mobile header below */
  .rd-searchwrap-desktop { display: none; }
  .rd-main { background: var(--bg); }
  .rd-body { display: block; min-height: 0; }
  #btn-filtros-mobile { display: none !important; }   /* FAB replaced by inline Filtros button */

  /* Give the scroll room above the fixed tab bar. */
  #main-content { padding-bottom: 4.5rem; }

  /* ---- Mobile header ---- */
  .rd-topbar-m {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 20px 12px; background: var(--bg);
    border-bottom: 1px solid var(--line); position: relative;
  }
  .rd-topbar-m-right { display: flex; align-items: center; gap: 6px; }
  .rd-m-iconbtn {
    width: 36px; height: 36px; display: grid; place-items: center;
    background: var(--bg-2); border: none; border-radius: 10px;
    color: var(--ink-2); cursor: pointer; text-decoration: none;
  }
  .rd-m-iconbtn:hover { background: var(--bg-3); }
  .rd-m-avatarbtn {
    width: 36px; height: 36px; display: grid; place-items: center;
    background: var(--bg-2); border: none; border-radius: 10px;
    cursor: pointer; text-decoration: none; padding: 0;
  }
  .rd-m-avatarbtn:hover { background: var(--bg-3); }
  .rd-m-avatar {
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--brand-2); color: var(--brand-ink);
    font-size: 10px; font-weight: 700; display: grid; place-items: center;
    object-fit: cover; overflow: hidden;
  }
  /* Account menu opens on tap (hover doesn't apply on touch). */
  .rd-m-menu-wrap { position: relative; }
  .rd-m-menu.is-open { opacity: 1; visibility: visible; }

  /* ---- Title block ---- */
  .rd-m-title { display: block; padding: 14px 20px 10px; }
  .rd-m-title-h { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; line-height: 1; color: var(--ink); }
  .rd-m-title-sub { font-size: 13px; color: var(--ink-3); margin-top: 4px; }

  /* ---- Portfolio breadcrumb ---- */
  .rd-pf-crumb { padding: 12px 16px 10px; }
  .rd-pf-name { font-size: 16px; }

  /* ---- Search + Filtros button ---- */
  .rd-m-searchwrap { display: block; padding: 4px 16px 10px; }
  .rd-m-searchbar {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 12px; background: #fff;
    border: 1px solid var(--line); border-radius: 12px;
  }
  .rd-m-searchbar:focus-within { border-color: var(--brand); }
  .rd-m-searchbar input {
    flex: 1; border: none; outline: none; background: transparent;
    font-size: 16px; font-family: var(--rd-sans); color: var(--ink); min-width: 0;
  }
  .rd-m-searchgo {
    flex-shrink: 0; display: grid; place-items: center;
    width: 34px; height: 34px; margin: -4px -4px -4px 0;
    background: var(--brand); color: #fff; border: none; border-radius: 9px; cursor: pointer;
  }
  .rd-m-searchgo:hover { filter: brightness(0.96); }
  .rd-m-filterbtn {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    width: 100%; margin-top: 8px; padding: 9px 14px;
    background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
    font-size: 13px; font-weight: 500; color: var(--ink); cursor: pointer;
  }
  .rd-m-filterbtn:hover { background: var(--bg-2); }
  .rd-m-filterbadge {
    font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 999px;
    background: var(--brand); color: #fff;
  }

  /* ---- Applied chips (horizontal scroll) ---- */
  .rd-m-chips { display: flex; gap: 5px; padding: 0 16px 4px; overflow-x: auto; white-space: nowrap; }
  .rd-m-chips::-webkit-scrollbar { display: none; }
  .rd-m-chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 5px 4px 8px; font-size: 11px; flex-shrink: 0;
    background: var(--brand-3); border: 1px solid var(--brand-2);
    border-radius: 7px; color: var(--brand-ink); cursor: default;
  }
  .rd-m-chip-g { font-size: 10px; opacity: .6; font-family: var(--rd-mono); }
  .rd-m-chip button { background: none; border: none; padding: 0; margin: 0; display: inline-flex; color: var(--brand-ink); cursor: pointer; }

  /* ---- Insight card ---- */
  .rd-insight {
    display: block; margin: 6px 16px 4px; padding: 10px 12px;
    background: var(--brand-3); border: 1px solid var(--brand-2); border-radius: 12px;
  }
  .rd-insight > div { align-items: flex-start !important; gap: 10px !important; }
  .rd-insight-icon { width: 26px; height: 26px; }
  .rd-insight-title { font-size: 12.5px; line-height: 1.35; }
  .rd-insight-sub { display: none; }
  .rd-insight-cta {
    margin-top: 6px; padding: 6px 11px; font-size: 11px; white-space: nowrap;
    margin-left: 36px;   /* align with the title text: icon (26px) + gap (10px) */
    align-self: flex-start;
  }

  /* ---- Count + select-all + actions ----
     Single row: count on the left, icon-only action buttons on the right.
     Dropping the button labels on mobile keeps everything on one line even for
     long counts like "~71.9 milhões empresas". */
  .rd-results-head {
    padding: 10px 16px; gap: 8px; background: var(--bg-2);
    border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  }
  .rd-results-head > div:first-child { gap: 8px !important; min-width: 0; }
  .rd-results-count { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .rd-results-head .rd-btn-label { display: none; }   /* icon-only buttons on mobile */
  .rd-m-check {
    display: grid; place-items: center; appearance: none; -webkit-appearance: none;
    width: 16px; height: 16px; border: 1.5px solid var(--line); border-radius: 4px;
    background: #fff; cursor: pointer; flex-shrink: 0; margin: 0;
  }
  .rd-m-check:checked { background: var(--brand); border-color: var(--brand); }
  .rd-m-check:checked::after {
    content: ""; width: 9px; height: 5px; margin-top: -2px;
    border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(-45deg);
  }
  .rd-results-head > div:last-child { gap: 6px !important; flex-shrink: 0; margin-left: auto; }
  /* All three actions become equal-size icon squares. */
  .rd-results-head #btn-add-portfolio,
  .rd-results-head #btn-export,
  .rd-results-head .rd-btn-icon {
    width: 34px; height: 34px; padding: 0; gap: 0;
    justify-content: center; flex-shrink: 0; border-radius: 8px;
  }
  .rd-results-head #btn-add-portfolio { background: #fff; border: 1px solid var(--line); color: var(--ink-2); }

  /* ---- Result rows (JS renders .rd-m-row markup) ---- */
  #results-cards { background: var(--bg); }
  .rd-m-row { display: flex; align-items: flex-start; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line-2); text-decoration: none; }
  .rd-m-row:active { background: var(--bg-2); }
  .rd-m-row-check { background: transparent; border: none; padding: 2px 2px 0 0; cursor: pointer; flex-shrink: 0; display: flex; }
  .rd-m-row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  /* Razão social is the main (linked) name; nome fantasia is an optional subtitle. */
  .rd-m-row-razao { font-size: 13.5px; font-weight: 600; color: var(--brand-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .rd-m-row-fantasia { font-size: 11.5px; font-weight: 500; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
  .rd-m-row-meta { font-size: 11px; color: var(--ink-3); margin-top: 3px; display: flex; gap: 6px; }
  .rd-m-row-chips { display: flex; gap: 4px; margin-top: 6px; }
  .rd-m-microchip { display: inline-flex; align-items: center; justify-content: center; gap: 3px; min-width: 22px; padding: 3px 6px; font-size: 10px; background: var(--bg-2); border-radius: 4px; }
  .rd-m-microchip-empty { background: transparent; color: var(--ink-4); }

  /* ---- Pagination (compact) ---- */
  .rd-pagination { padding: 12px 16px; border-top: 1px solid var(--line); justify-content: center; }
  .rd-pagination #page-info { width: 100%; text-align: center; }

  /* Empty / loading states. */
  #search-placeholder, #search-loading { padding-top: 3.5rem; padding-bottom: 3.5rem; }

  /* ================= Filter column as a BOTTOM SHEET ================= */
  #sidebar.rd-filtercol {
    position: fixed; left: 0; right: 0; bottom: 0; top: 14%;
    width: 100% !important; max-width: 100%;
    padding-top: 0 !important;
    border: none; border-radius: 20px 20px 0 0;
    box-shadow: 0 -8px 30px rgba(0,0,0,.15);
    transform: translateY(100%);
    transition: transform .25s ease-out;
    z-index: 41;
  }
  #sidebar.rd-filtercol.sidebar-open-mobile { transform: translateY(0); }
  #sidebar-backdrop { z-index: 40; }

  .rd-sheet-handle { display: block; width: 36px; height: 4px; border-radius: 2px; background: var(--line); margin: 10px auto 4px; flex-shrink: 0; }
  /* Sheet header: "Filtros" + close ✕; hide desktop headings & inline Limpar. */
  .rd-filter-header { padding: 6px 20px 12px; border-bottom: 1px solid var(--line-2); align-items: center; }
  .rd-filter-headings, #btn-limpar-filtros { display: none; }
  .rd-sheet-title { display: block; font-size: 16px; font-weight: 700; color: var(--ink); }
  #toggle-icon-expand, #toggle-icon-collapse { display: none !important; }
  .rd-sheet-x { display: block; }
  #sidebar-toggle { width: 30px; height: 30px; background: var(--bg-2); border-radius: 8px; }

  /* Footer: Limpar + Buscar side by side. */
  .rd-filter-footer { display: flex; gap: 8px; padding: 12px 20px 24px; }
  .rd-sheet-clear {
    display: block; flex: 1; padding: 12px; font-size: 13.5px; font-weight: 600;
    background: #fff; border: 1px solid var(--line); border-radius: 10px; color: var(--ink-2); cursor: pointer;
  }
  .rd-btn-buscar { flex: 2; border-radius: 10px; padding: 12px; }

  /* ---- Bottom tab bar ---- */
  .rd-tabbar {
    display: flex; justify-content: space-around; align-items: flex-start;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
    background: rgba(255,255,255,.94);
    backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid var(--line);
  }
  .rd-tab {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 4px 8px; background: none; border: none; cursor: pointer;
    color: var(--ink-3); text-decoration: none; font-size: 10px; font-weight: 500;
  }
  .rd-tab.is-active { color: var(--brand-ink); font-weight: 600; }
  .rd-tab.is-disabled { opacity: .4; pointer-events: none; }
  .rd-tab-soon { display: block; font-size: 8px; }
}
