/* =========================================================
   CRM CLUBE AUTÊNTICO — design system + app layout
   Warm neutrals, amber accent, Poppins.
   ========================================================= */

:root {
  /* Neutros */
  --bg: #f7f4ee;
  --bg-soft: #fbf8f1;
  --surface: #ffffff;
  --surface-alt: #f4efe5;
  --surface-sunken: #efe9db;

  --text: #1a1612;
  --text-soft: #5a4f43;
  --text-mute: #8c8071;

  --line: rgba(26, 22, 18, 0.10);
  --line-strong: rgba(26, 22, 18, 0.18);
  --line-input: rgba(26, 22, 18, 0.18);

  /* Marca */
  --brand: #b07418;
  --brand-deep: #82550e;
  --brand-soft: rgba(176, 116, 24, 0.10);
  --accent: #d9a825;
  --accent-soft: rgba(217, 168, 37, 0.16);

  /* Estados */
  --danger: #b53227;
  --danger-soft: rgba(181, 50, 39, 0.10);
  --warning: #b07a16;
  --warning-soft: rgba(176, 122, 22, 0.14);
  --success: #2e7c3b;
  --success-soft: rgba(46, 124, 59, 0.12);
  --info: #2f6da6;
  --info-soft: rgba(47, 109, 166, 0.10);

  /* Sidebar (dark) */
  --nav-bg: #1a1612;
  --nav-surface: #25201a;
  --nav-line: rgba(255, 255, 255, 0.08);
  --nav-text: #d9d2c4;
  --nav-text-mute: #8c8071;
  --nav-text-active: #ffffff;

  /* Aliases legados */
  --surface-strong: var(--surface);
  --surface-warm: var(--surface);
  --surface-dark: var(--brand-deep);
  --brand-strong: var(--brand-deep);

  --shadow-xs: 0 1px 1px rgba(26, 22, 18, 0.04);
  --shadow-sm: 0 1px 2px rgba(26, 22, 18, 0.06);
  --shadow-md: 0 4px 12px rgba(26, 22, 18, 0.08);
  --shadow-lg: 0 12px 28px rgba(26, 22, 18, 0.12);
  --shadow-pop: 0 18px 40px rgba(26, 22, 18, 0.18);

  --radius-xl: 14px;
  --radius-lg: 12px;
  --radius-md: 8px;
  --radius-sm: 6px;

  --ring: 0 0 0 3px rgba(176, 116, 24, 0.25);

  --row-y: 0.7rem;
  --card-pad: 1.1rem;
  --gap: 0.85rem;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.75rem;
  --space-7: 2.5rem;

  --motion-fast: 110ms cubic-bezier(0.2, 0.7, 0.2, 1);
  --motion-base: 200ms cubic-bezier(0.2, 0.7, 0.2, 1);

  --font-body: "Poppins", "Segoe UI", system-ui, sans-serif;
  --font-display: var(--font-body);
  --font-mono: "Poppins", ui-monospace, monospace;
}

/* Density modes (tweakable via data-density on <html>) */
:root[data-density="compact"]  { --row-y: 0.5rem;  --card-pad: 0.85rem; --gap: 0.6rem; }
:root[data-density="spacious"] { --row-y: 0.95rem; --card-pad: 1.4rem;  --gap: 1.15rem; }
:root[data-emphasis="bold"]    { --bg: #f3ecd9; --surface-alt: #ece1c6; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body, body.crm-body {
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button { font-family: inherit; }

.crm-body::before { content: none; }

.crm-shell { position: relative; z-index: 1; }

/* =========================================================
   APP SHELL — sidebar + topbar + content (+ optional rail)
   ========================================================= */

.app {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}

.app-main {
  display: grid;
  grid-template-rows: 56px 1fr;
  min-width: 0;
}

.app-content {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: var(--gap);
  padding: var(--gap);
  min-width: 0;
  align-content: start;
}

.app-content[data-rail="off"] {
  grid-template-columns: 1fr;
}
.app-content[data-rail="off"] .rail { display: none; }

.app-col { min-width: 0; display: grid; gap: var(--gap); align-content: start; }

/* =========================================================
   SIDEBAR (dark)
   ========================================================= */

.sidebar {
  background: var(--nav-bg);
  color: var(--nav-text);
  display: grid;
  grid-template-rows: auto 1fr auto;
  border-right: 1px solid rgba(255,255,255,0.04);
}

.icon-btn.mobile-menu-toggle,
.mobile-menu-backdrop {
  display: none;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.95rem 1rem;
  border-bottom: 1px solid var(--nav-line);
}

.sidebar-mark {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: linear-gradient(140deg, #d9a825, #82550e);
  color: #1a1612;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
}

.sidebar-brand-text { display: grid; line-height: 1.1; }
.sidebar-brand-text strong {
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.sidebar-brand-text span {
  color: var(--nav-text-mute);
  font-size: 0.7rem;
  font-family: var(--font-mono);
}

.sidebar-nav {
  padding: 0.75rem 0.55rem;
  display: grid;
  gap: 0.1rem;
  align-content: start;
  overflow-y: auto;
}

.nav-group {
  font-family: var(--font-body);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0;
  
  color: var(--nav-text-mute);
  padding: 0.7rem 0.7rem 0.35rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.7rem;
  border-radius: 7px;
  color: var(--nav-text);
  text-decoration: none;
  background: transparent;
  border: 0;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: background var(--motion-fast), color var(--motion-fast);
}
.nav-item:hover { background: rgba(255,255,255,0.04); color: #fff; }
.nav-item.is-active {
  background: rgba(217, 168, 37, 0.12);
  color: var(--nav-text-active);
}
.nav-item.is-active .nav-icon { color: var(--accent); }

.nav-icon {
  width: 16px; height: 16px;
  flex: 0 0 16px;
  color: var(--nav-text-mute);
  transition: color var(--motion-fast);
}
.nav-icon svg { width: 16px; height: 16px; display: block; }
.nav-item:hover .nav-icon { color: var(--nav-text); }

.nav-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--nav-text-mute);
  background: rgba(255,255,255,0.05);
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
}
.nav-item.is-active .nav-count { color: var(--accent); background: rgba(217,168,37,0.14); }

.sidebar-foot {
  border-top: 1px solid var(--nav-line);
  padding: 0.7rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.avatar {
  width: 30px; height: 30px;
  border-radius: 999px;
  background: linear-gradient(140deg, #d9a825, #82550e);
  color: #1a1612;
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 600;
}

.user-text { display: grid; line-height: 1.15; min-width: 0; }
.user-text strong { color: #fff; font-size: 0.8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-text span { color: var(--nav-text-mute); font-size: 0.7rem; }

/* =========================================================
   TOPBAR
   ========================================================= */

.topbar {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0 var(--gap);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  height: 56px;
}

.crumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.84rem;
  color: var(--text-soft);
  min-width: 0;
}
.crumb strong { color: var(--text); font-weight: 600; }
.crumb-sep { color: var(--text-mute); display: inline-flex; }
.crumb-sep svg { width: 12px; height: 12px; }

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 560px;
  margin-left: auto;
}

.search-input {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.6rem 0.45rem 2.1rem;
  font-size: 0.88rem;
  color: var(--text);
  font-family: var(--font-body);
  transition: border-color var(--motion-fast), background var(--motion-fast), box-shadow var(--motion-fast);
}
.search-input::placeholder { color: var(--text-mute); }
.search-input:focus {
  outline: 0;
  background: #fff;
  border-color: var(--brand);
  box-shadow: var(--ring);
}

.search-icon {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  color: var(--text-mute);
  pointer-events: none;
  display: inline-flex;
}
.search-icon svg { width: 14px; height: 14px; }

.search-kbd {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-mute);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
  pointer-events: none;
}

.search-pop {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  z-index: 50;
  max-height: 420px;
  overflow-y: auto;
}

.search-section {
  font-family: var(--font-body);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0;
  
  color: var(--text-mute);
  padding: 0.6rem 0.85rem 0.25rem;
}

.search-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.85rem;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background var(--motion-fast);
}
.search-row:hover, .search-row.is-focused {
  background: var(--bg-soft);
  border-left-color: var(--accent);
}
.search-row .avatar { width: 32px; height: 32px; font-size: 0.78rem; }
.search-row-main { display: grid; gap: 0.05rem; min-width: 0; flex: 1; }
.search-row-main .name { font-weight: 600; font-size: 0.88rem; color: var(--text); }
.search-row-main .meta { font-family: var(--font-mono); font-size: 0.74rem; color: var(--text-mute); }
.search-row .right-meta {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-soft);
  white-space: nowrap;
}

.search-empty {
  padding: 1rem 0.85rem;
  color: var(--text-mute);
  font-size: 0.85rem;
}

.topbar-actions { display: flex; align-items: center; gap: 0.4rem; }

.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text-soft);
  cursor: pointer;
  position: relative;
  transition: background var(--motion-fast), color var(--motion-fast), border-color var(--motion-fast);
}
.icon-btn:hover { background: var(--surface-alt); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; }
.crm-notifications-link { position: relative; text-decoration: none; }
.crm-notifications-count {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border: 2px solid var(--surface, #fff);
  border-radius: 10px;
  background: #c43f43;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 13px;
  text-align: center;
}
.icon-btn .dot {
  position: absolute;
  top: 7px; right: 7px;
  width: 7px; height: 7px;
  background: var(--danger);
  border: 2px solid var(--surface);
  border-radius: 999px;
}

/* =========================================================
   TYPOGRAPHY
   ========================================================= */

.page-title,
.crm-hero-title {
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0;
  line-height: 1.15;
  font-family: var(--font-body);
}

.page-sub,
.crm-hero-text {
  color: var(--text-soft);
  font-size: 0.86rem;
  margin: 0.2rem 0 0;
}

.eyebrow,
.crm-section-title {
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0;
  
  color: var(--text-mute);
  font-family: var(--font-body);
}
.crm-section-title {
  color: var(--text-soft);
  font-size: 0.72rem;
  letter-spacing: 0;
  margin-bottom: 0.7rem;
}

.crm-card-title {
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0;
}

.crm-subtitle {
  color: var(--text-soft);
  font-size: 0.88rem;
  line-height: 1.5;
}

.crm-label {
  display: block;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0;
  
  color: var(--text-soft);
  margin-bottom: 0.4rem;
}

.mono,
.crm-mono { font-family: var(--font-mono); font-feature-settings: "tnum","lnum"; }

/* =========================================================
   CARDS
   ========================================================= */

.card,
.crm-card,
.crm-glass {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: var(--card-pad);
  box-shadow: var(--shadow-xs);
  min-width: 0;
  transition: border-color var(--motion-base), box-shadow var(--motion-base);
}
.card:hover, .crm-card:hover { border-color: var(--line-strong); }
.card-pad-0 { padding: 0; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  margin-bottom: 0.85rem;
}
.card-title { font-size: 0.95rem; font-weight: 600; letter-spacing: -0.01em; color: var(--text); margin: 0; }
.card-sub { font-size: 0.78rem; color: var(--text-soft); margin: 0.15rem 0 0; }
.card-link {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--brand-deep);
  background: transparent;
  border: 0;
  cursor: pointer;
  text-decoration: none;
}
.card-link:hover { color: var(--brand); text-decoration: underline; }

/* =========================================================
   METRIC GRID
   ========================================================= */

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--gap);
}

.metric,
.crm-metric-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: var(--card-pad);
  overflow: hidden;
  display: grid;
  gap: 0.4rem;
  min-width: 0;
}
.metric::before,
.crm-metric-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 28px; height: 2px;
  background: var(--accent);
  transition: width var(--motion-base);
}
.metric:hover::before,
.crm-metric-card:hover::before { width: 56px; }
.crm-metric-card::after { content: none; }

.metric-label,
.crm-metric-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0;
  
  color: var(--text-soft);
}
.metric-value,
.crm-metric-value {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.1;
  letter-spacing: -0.01em;
}
.metric-foot {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.76rem;
  color: var(--text-mute);
}

.delta {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 500;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
}
.delta-up { color: var(--success); background: var(--success-soft); }
.delta-down { color: var(--danger); background: var(--danger-soft); }
.delta-flat { color: var(--text-soft); background: var(--surface-alt); }

/* =========================================================
   PILLS / BADGES (.pill — design; .crm-pill — legado)
   ========================================================= */

.pill,
.crm-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  font-family: var(--font-body);
}
.pill .pill-dot,
.crm-pill .pill-dot {
  width: 6px; height: 6px;
  border-radius: 999px;
  background: currentColor;
}
.pill-soft,    .crm-pill-soft    { color: var(--brand-deep); background: var(--brand-soft); }
.pill-brand,   .crm-pill-brand   { color: #fff; background: var(--brand); }
.pill-success, .crm-pill-success { color: var(--success); background: var(--success-soft); }
.pill-warning, .crm-pill-warning { color: var(--warning); background: var(--warning-soft); }
.pill-danger,  .crm-pill-danger  { color: var(--danger);  background: var(--danger-soft); }
.pill-info,    .crm-pill-info    { color: var(--info);    background: var(--info-soft); }
.pill-mute                       { color: var(--text-soft); background: var(--surface-alt); }

/* =========================================================
   BUTTONS (.btn — design; .crm-btn — legado)
   ========================================================= */

.btn,
.crm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.5rem 0.85rem;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.84rem;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--motion-fast), color var(--motion-fast),
              border-color var(--motion-fast), transform var(--motion-fast),
              box-shadow var(--motion-fast);
}
.btn:active, .crm-btn:active { transform: translateY(0.5px); }
.btn:focus-visible, .crm-btn:focus-visible { outline: 0; box-shadow: var(--ring); }
.btn:disabled, .crm-btn:disabled, .crm-btn.is-loading { opacity: 0.55; cursor: not-allowed; }

.btn-primary,   .crm-btn-primary   { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover, .crm-btn-primary:hover { background: var(--brand-deep); border-color: var(--brand-deep); color: #fff; }

.btn-secondary, .crm-btn-secondary { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.btn-secondary:hover, .crm-btn-secondary:hover { background: var(--surface-alt); border-color: var(--text-soft); color: var(--text); }

.btn-dark,      .crm-btn-dark      { background: var(--text); color: #fff; border-color: var(--text); }
.btn-dark:hover, .crm-btn-dark:hover { background: #000; border-color: #000; color: #fff; }

.btn-ghost,     .crm-btn-ghost     { background: transparent; color: var(--text); }
.btn-ghost:hover, .crm-btn-ghost:hover { background: var(--surface-alt); }

.btn-danger,    .crm-btn-danger    { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover, .crm-btn-danger:hover { background: #8e2820; border-color: #8e2820; color: #fff; }

.btn-warning,   .crm-btn-warning   { background: var(--accent); color: var(--text); border-color: var(--accent); }
.btn-warning:hover, .crm-btn-warning:hover { background: var(--brand); color: #fff; border-color: var(--brand); }

.btn-sm { padding: 0.35rem 0.6rem; font-size: 0.78rem; }
.btn-block { width: 100%; }

/* =========================================================
   INPUTS (.input — design; .crm-input — legado)
   ========================================================= */

.input, .select, .textarea,
.crm-input, .crm-select, .crm-textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line-input);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
  line-height: 1.4;
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast);
}
.input::placeholder, .textarea::placeholder,
.crm-input::placeholder, .crm-textarea::placeholder {
  color: var(--text-mute);
}
.input:focus, .select:focus, .textarea:focus,
.crm-input:focus, .crm-select:focus, .crm-textarea:focus {
  outline: 0;
  border-color: var(--brand);
  box-shadow: var(--ring);
}

.field { display: grid; gap: 0.35rem; }
.field-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0;
  
  color: var(--text-soft);
}

.input-with-prefix { position: relative; }
.input-with-prefix .prefix {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-mute);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}
.input-with-prefix .input { padding-left: 1.9rem; }

/* =========================================================
   TABLES (.t — design; .crm-table-shell — legado)
   ========================================================= */

.table-shell,
.crm-table-shell {
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface);
}
.table-shell.no-border,
.crm-table-shell.no-border { border: 0; border-radius: 0; }

.t,
.crm-table-shell table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0;
}
.t thead th,
.crm-table-shell thead th {
  background: var(--surface-alt);
  color: var(--text-soft);
  font-size: 0.68rem;
  
  letter-spacing: 0;
  font-weight: 600;
  padding: 0.55rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--line-strong);
}
.t tbody td,
.crm-table-shell tbody td {
  padding: var(--row-y) 0.85rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.86rem;
  vertical-align: middle;
}
.t tbody tr:last-child td,
.crm-table-shell tbody tr:last-child td { border-bottom: 0; }
.t tbody tr,
.crm-table-shell tbody tr { transition: background var(--motion-fast); }
.t tbody tr:hover,
.crm-table-shell tbody tr:hover { background: var(--bg-soft); }
.t tbody tr.is-selected { background: var(--accent-soft); }
.t .num { font-family: var(--font-mono); font-feature-settings: "tnum","lnum"; }
.t .right { text-align: right; }

.row-client {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.row-client .avatar { width: 28px; height: 28px; font-size: 0.7rem; }
.row-client .name { font-weight: 600; }
.row-client .sub { font-family: var(--font-mono); font-size: 0.74rem; color: var(--text-mute); }

/* =========================================================
   CLIENT DETAIL
   ========================================================= */

.client-header {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.1rem 1.2rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1.1rem;
  align-items: center;
}

.client-avatar {
  width: 56px; height: 56px;
  border-radius: 999px;
  background: linear-gradient(140deg, #d9a825, #82550e);
  color: #1a1612;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  font-weight: 600;
  flex: 0 0 56px;
}

.client-name {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
}
.client-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  color: var(--text-soft);
  font-size: 0.82rem;
  margin-top: 0.25rem;
  align-items: center;
}
.client-meta .dot {
  width: 3px; height: 3px;
  border-radius: 999px;
  background: var(--text-mute);
  display: inline-block;
}
.client-meta .mono { color: var(--text); }

.client-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--gap);
}

/* Score block */
.score-card { display: grid; gap: 0.6rem; }
.score-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 1rem;
  align-items: center;
}
.score-row .speedometer { position: relative; width: 160px; height: 92px; }
.score-row .speedometer svg { width: 100%; height: auto; display: block; }
.score-row .speedometer-value {
  position: absolute;
  bottom: 2px;
  left: 0; right: 0;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 500;
}
.score-row .speedometer-label {
  position: absolute;
  top: 38px;
  left: 0; right: 0;
  text-align: center;
  font-size: 0.66rem;
  color: var(--text-mute);
  
  letter-spacing: 0;
}
.score-band {
  display: grid;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: var(--text-soft);
}
.score-band .row {
  display: flex; justify-content: space-between;
  border-bottom: 1px dashed var(--line);
  padding: 0.2rem 0;
}
.score-band .row:last-child { border-bottom: 0; }

/* Categoria */
.cat-card { display: grid; grid-template-columns: auto 1fr; gap: 0.9rem; align-items: center; }
.medal,
.categoria-medalha {
  position: relative;
  display: grid;
  place-items: center;
  width: 64px; height: 64px;
  border-radius: 999px;
  font-size: 1.5rem;
  font-weight: 600;
  color: #fff9df;
  border: 3px solid rgba(255,255,255,0.78);
  box-shadow: 0 8px 18px rgba(26,22,18,0.16);
  isolation: isolate;
  background: linear-gradient(145deg, #ffd45c, #a76208);
  flex: 0 0 64px;
}
.medal::after,
.categoria-medalha::after {
  content: "";
  position: absolute;
  bottom: -13px;
  width: 24px; height: 20px;
  background: linear-gradient(180deg, #7b3b14, #4f260d);
  clip-path: polygon(0 0, 100% 0, 76% 100%, 50% 72%, 24% 100%);
  z-index: -1;
}
.categoria-bronze { background: linear-gradient(145deg, #b86b32, #6f3515); }
.categoria-prata  { background: linear-gradient(145deg, #d9d2c5, #8b8174); color: #3f2919; }
.categoria-ouro   { background: linear-gradient(145deg, #ffd45c, #a76208); color: #4b2608; }

.cat-name { font-size: 1.2rem; font-weight: 600; line-height: 1; }
.cat-sub { color: var(--text-soft); font-size: 0.84rem; margin-top: 0.2rem; }
.cat-progress {
  margin-top: 0.55rem;
  height: 5px;
  background: var(--surface-alt);
  border-radius: 999px;
  overflow: hidden;
}
.cat-progress > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--accent));
  border-radius: 999px;
}

/* Extrato */
.extrato {
  display: grid;
  gap: 0;
}
.extrato-item,
.crm-extrato-item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 0.7rem;
  padding: var(--row-y) 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  border-left: 0; border-right: 0; border-top: 0;
  border-radius: 0;
  align-items: flex-start;
}
.extrato-item:last-child,
.crm-extrato-item:last-child { border-bottom: 0; }
.extrato-mark {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--surface-alt);
  color: var(--text-soft);
}
.extrato-mark.credit { background: var(--success-soft); color: var(--success); }
.extrato-mark.debit  { background: var(--danger-soft); color: var(--danger); }
.extrato-mark.expire { background: var(--warning-soft); color: var(--warning); }
.extrato-mark.draw   { background: var(--info-soft); color: var(--info); }
.extrato-title { font-weight: 600; font-size: 0.9rem; color: var(--text); }
.extrato-sub   { color: var(--text-mute); font-family: var(--font-mono); font-size: 0.76rem; margin-top: 0.1rem; }
.extrato-amount {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  font-weight: 500;
  text-align: right;
  white-space: nowrap;
}
.extrato-amount.credit { color: var(--success); }
.extrato-amount.debit  { color: var(--danger); }
.extrato-amount.mute   { color: var(--text-mute); }

/* =========================================================
   ALERTS (.alert — design; .crm-alert-inline — legado)
   ========================================================= */

.alert,
.crm-alert-inline {
  position: relative;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 0.55rem 0.85rem 0.55rem 0.95rem;
  font-size: 0.85rem;
  background: var(--surface);
}
.alert::before,
.crm-alert-inline::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  border-radius: 8px 0 0 8px;
}
.alert-success, .crm-alert-success { color: var(--success); border-color: rgba(46,124,59,0.28); background: var(--success-soft); }
.alert-success::before, .crm-alert-success::before { background: var(--success); }
.alert-warning, .crm-alert-warning { color: var(--warning); border-color: rgba(176,122,22,0.28); background: var(--warning-soft); }
.alert-warning::before, .crm-alert-warning::before { background: var(--warning); }
.alert-danger,  .crm-alert-danger  { color: var(--danger); border-color: rgba(181,50,39,0.28); background: var(--danger-soft); }
.alert-danger::before, .crm-alert-danger::before { background: var(--danger); }
.alert-info, .crm-alert-info { color: var(--info); border-color: rgba(47,109,166,0.28); background: var(--info-soft); }
.alert-info::before, .crm-alert-info::before { background: var(--info); }

/* =========================================================
   RAIL (right column)
   ========================================================= */

.rail { display: grid; gap: var(--gap); align-content: start; }

.rail .quick-action {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  text-align: left;
  width: 100%;
  cursor: pointer;
  color: var(--text);
  font-size: 0.85rem;
  font-family: var(--font-body);
  transition: background var(--motion-fast), border-color var(--motion-fast);
}
.rail .quick-action:hover { background: #fff; border-color: var(--line-strong); }
.rail .quick-action .qi {
  width: 28px; height: 28px;
  border-radius: 7px;
  display: grid; place-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
}
.rail .quick-action strong { font-weight: 600; }
.rail .quick-action span { color: var(--text-mute); font-size: 0.74rem; }
.rail .quick-action kbd {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-mute);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.02rem 0.3rem;
}

/* Activity feed */
.feed { display: grid; gap: 0; }
.feed-item {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 0.55rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line);
}
.feed-item:last-child { border-bottom: 0; }
.feed-bullet {
  width: 8px; height: 8px;
  border-radius: 999px;
  background: var(--accent);
  margin-top: 0.45rem;
  justify-self: center;
}
.feed-bullet.mute { background: var(--text-mute); }
.feed-bullet.danger { background: var(--danger); }
.feed-bullet.success { background: var(--success); }
.feed-title { font-size: 0.84rem; }
.feed-title strong { font-weight: 600; }
.feed-meta { color: var(--text-mute); font-family: var(--font-mono); font-size: 0.72rem; margin-top: 0.1rem; }

/* =========================================================
   MODAL
   ========================================================= */

.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(26, 22, 18, 0.45);
  backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 1rem;
  animation: fadeBack 160ms ease-out;
}
@keyframes fadeBack { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: min(520px, 100%);
  background: var(--surface);
  border-radius: 14px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  animation: popUp 200ms cubic-bezier(0.2,0.7,0.2,1);
}
@keyframes popUp { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-head {
  padding: 1rem 1.2rem 0.6rem;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: flex-start; gap: 0.8rem;
}
.modal-head h3 { margin: 0; font-size: 1.05rem; font-weight: 600; letter-spacing: -0.01em; }
.modal-head p { margin: 0.15rem 0 0; color: var(--text-soft); font-size: 0.84rem; }

.modal-tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  padding: 0 1.2rem;
  gap: 0.2rem;
}
.modal-tab {
  background: transparent;
  border: 0;
  padding: 0.7rem 0.85rem;
  font-weight: 600;
  font-size: 0.86rem;
  color: var(--text-soft);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  display: flex; align-items: center; gap: 0.4rem;
  font-family: var(--font-body);
}
.modal-tab:hover { color: var(--text); }
.modal-tab.is-active { color: var(--text); border-bottom-color: var(--brand); }

.modal-body { padding: 1.1rem 1.2rem; display: grid; gap: 0.85rem; }
.modal-foot {
  padding: 0.85rem 1.2rem;
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  align-items: center;
}
.modal-foot .left { margin-right: auto; color: var(--text-soft); font-size: 0.8rem; }

.amount-preview {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  display: flex; align-items: baseline; justify-content: space-between;
}
.amount-preview .label { font-size: 0.74rem; color: var(--text-soft); letter-spacing: 0; font-weight: 600; }
.amount-preview .value { font-family: var(--font-mono); font-size: 1.6rem; font-weight: 500; }

.chip-row { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.chip {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-mono);
  transition: all var(--motion-fast);
}
.chip:hover { border-color: var(--brand); }
.chip.is-active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* =========================================================
   TOAST
   ========================================================= */

.toast-stack {
  position: fixed;
  bottom: 1.2rem; right: 1.2rem;
  display: grid; gap: 0.5rem;
  z-index: 200;
  max-width: 360px;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: flex-start; gap: 0.55rem;
  animation: popUp 180ms cubic-bezier(0.2,0.7,0.2,1);
}
.toast-icon {
  width: 22px; height: 22px;
  border-radius: 999px;
  display: grid; place-items: center;
  background: var(--success-soft); color: var(--success);
  flex: 0 0 22px;
}
.toast.danger .toast-icon { background: var(--danger-soft); color: var(--danger); }
.toast strong { font-weight: 600; font-size: 0.86rem; }
.toast p { margin: 0.05rem 0 0; font-size: 0.8rem; color: var(--text-soft); }

/* =========================================================
   CHART (sparkline / bars)
   ========================================================= */

.sparkline { height: 60px; width: 100%; display: block; }

.bar-chart {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  align-items: end;
  gap: 0.4rem;
  height: 110px;
}
.bar {
  background: linear-gradient(180deg, var(--accent), var(--brand));
  border-radius: 4px 4px 2px 2px;
  position: relative;
  min-height: 4px;
  transition: filter var(--motion-fast);
}
.bar:hover { filter: brightness(1.08); }
.bar .bar-label {
  position: absolute;
  bottom: -1.25rem;
  left: 0; right: 0;
  text-align: center;
  font-size: 0.66rem;
  color: var(--text-mute);
  font-family: var(--font-mono);
}
.bar-chart-wrap { padding-bottom: 1.4rem; }

/* =========================================================
   EMPTY STATE
   ========================================================= */

.empty,
.crm-empty {
  padding: 1.5rem;
  border-radius: 10px;
  border: 1px dashed var(--line-strong);
  color: var(--text-soft);
  background: var(--bg-soft);
  text-align: center;
  font-size: 0.88rem;
}

/* =========================================================
   DETAIL CARDS (legado)
   ========================================================= */

.crm-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.65rem;
}
.crm-detail-card {
  padding: 0.75rem 0.85rem;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  transition: border-color var(--motion-base);
}
.crm-detail-card:hover { border-color: var(--line-strong); }
.crm-detail-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0;
  
  color: var(--text-soft);
  margin-bottom: 0.25rem;
}
.crm-detail-value {
  font-family: var(--font-mono);
  font-weight: 500;
  margin-top: 0.3rem;
  font-size: 0.96rem;
  color: var(--text);
  font-feature-settings: "tnum","lnum";
}

.crm-divider {
  height: 1px;
  width: 100%;
  background: var(--line);
  margin: 1rem 0;
}

.crm-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.crm-extrato-list {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line);
}
.crm-extrato-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: baseline;
}
.crm-extrato-type {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text);
}
.crm-extrato-meta {
  color: var(--text-mute);
  font-size: 0.78rem;
  font-family: var(--font-mono);
}

/* Loading skeletons */
.crm-skeleton {
  background: linear-gradient(90deg,
    rgba(26, 22, 18, 0.05) 0%,
    rgba(26, 22, 18, 0.10) 50%,
    rgba(26, 22, 18, 0.05) 100%);
  background-size: 200% 100%;
  border-radius: var(--radius-sm);
  animation: crmSkeleton 1.4s ease-in-out infinite;
  color: transparent;
}
@keyframes crmSkeleton {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.crm-spinner {
  display: inline-block;
  width: 1em; height: 1em;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: crmSpin 0.7s linear infinite;
}
@keyframes crmSpin { to { transform: rotate(360deg); } }

.crm-fade-in {
  animation: crmFadeIn 0.35s ease-out both;
}
@keyframes crmFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* =========================================================
   FOCUS RING ALL BUTTONS
   ========================================================= */
button:focus-visible { outline: 0; box-shadow: var(--ring); border-radius: 8px; }

/* =========================================================
   SCROLLBAR
   ========================================================= */
@media (pointer: fine) {
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb {
    background: rgba(26, 22, 18, 0.18);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
  }
  ::-webkit-scrollbar-thumb:hover {
    background: rgba(26, 22, 18, 0.35);
    background-clip: padding-box;
    border: 2px solid transparent;
  }
}

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

/* =========================================================
   RESPONSIVE — collapse rail + sidebar
   ========================================================= */
@media (max-width: 1180px) {
  .app-content { grid-template-columns: 1fr; }
  .rail { display: none; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .icon-btn.mobile-menu-toggle {
    display: grid;
    flex: 0 0 34px;
  }
  .sidebar {
    display: grid;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1001;
    width: min(84vw, 300px);
    max-width: calc(100vw - 48px);
    height: 100vh;
    height: 100dvh;
    box-shadow: 18px 0 44px rgba(7, 15, 18, 0.28);
    transform: translateX(-105%);
    visibility: hidden;
    transition:
      transform 180ms ease,
      visibility 0s linear 180ms;
  }
  .mobile-menu-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1000;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: rgba(9, 18, 21, 0.52);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition:
      opacity 180ms ease,
      visibility 0s linear 180ms;
  }
  body.mobile-menu-open {
    overflow: hidden;
  }
  body.mobile-menu-open .sidebar {
    transform: translateX(0);
    visibility: visible;
    transition-delay: 0s;
  }
  body.mobile-menu-open .mobile-menu-backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition-delay: 0s;
  }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .topbar {
    gap: 0.5rem;
    padding: 0 0.75rem;
  }
  .crumb {
    display: none;
  }
  .search-wrap {
    min-width: 0;
    margin-left: 0;
  }
  .search-kbd {
    display: none;
  }
  .topbar-actions {
    margin-left: auto;
  }
  .metric-grid { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: 1fr; }
}
/* ===== CRM no celular (≤ 860px). Acima disso nada muda. ===== */
.crm-bnav, .crm-mais, .topbar-marca, .topbar-titulo, .crm-filtros-botao, .crm-filtros-ver, .crm-filtros-fundo { display: none; }

@media (max-width: 860px) {
  :root { --crm-bnav-h: calc(62px + env(safe-area-inset-bottom, 0px)); --crm-acao-h: 0px; }
  html, body { overflow-x: hidden; }
  body { padding-bottom: calc(var(--crm-bnav-h) + var(--crm-acao-h) + 12px) !important; }
  .sidebar, .mobile-menu-backdrop, .icon-btn.mobile-menu-toggle { display: none !important; }
  .app, .app-main, .app-col, .app-content { min-width: 0; max-width: 100vw; }

  /* Barra inferior */
  .crm-bnav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1040; height: var(--crm-bnav-h); padding-bottom: env(safe-area-inset-bottom, 0px); background: #1d1813; box-shadow: 0 -2px 10px rgba(0, 0, 0, .2); }
  .crm-bnav-item { flex: 1; min-width: 0; min-height: 44px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; background: none; color: #b7ab98; font: inherit; font-size: 11px; text-decoration: none; }
  .crm-bnav-item[hidden] { display: none; }
  .crm-bnav-item.is-on, .crm-bnav-item[aria-current="page"] { color: #f2c879; font-weight: 600; }

  /* Mais */
  .crm-mais { display: flex; flex-direction: column; gap: 12px; position: fixed; inset: 0 0 var(--crm-bnav-h) 0; z-index: 1035; padding: 0 14px 16px; overflow-y: auto; background: var(--bg, #f4efe7); }
  .crm-mais[hidden] { display: none; }
  .crm-mais-topo { display: flex; align-items: center; justify-content: space-between; height: 56px; }
  .crm-mais-topo h2 { margin: 0; font-size: 17px; font-weight: 700; }
  .crm-mais-fechar { width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: none; color: inherit; }
  .crm-mais-user { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 14px; background: #fff; border: 1px solid rgba(58, 36, 20, .1); }
  .crm-mais-user strong { display: block; font-size: 16px; }
  .crm-mais-user span:not(.avatar) { font-size: 13px; color: #776c5f; }
  .crm-mais-lista { display: flex; flex-direction: column; border-radius: 14px; background: #fff; border: 1px solid rgba(58, 36, 20, .1); overflow: hidden; }
  .crm-mais-item { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 6px 16px; border-top: 1px solid rgba(58, 36, 20, .08); color: #1d1813; font-size: 15px; font-weight: 500; text-decoration: none; }
  .crm-mais-item:first-child { border-top: 0; }
  .crm-mais-item .ic { width: 36px; height: 36px; flex: none; border-radius: 10px; display: grid; place-items: center; color: #fff; }
  .crm-mais-item .ic svg { width: 18px; height: 18px; }
  .crm-mais-item .nome { flex: 1; }
  .crm-mais-item .seta { font-size: 22px; color: #9a8f80; }
  .crm-mais-sair { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; border-radius: 14px; background: #fff; border: 1px solid rgba(58, 36, 20, .1); color: #b53227; font-weight: 600; text-decoration: none; }
  body.crm-mais-aberto { overflow: hidden; }

  /* Topo */
  .topbar { height: 56px; min-height: 56px; padding: 0 12px !important; gap: 10px !important; position: sticky; top: 0; z-index: 1020; }
  .app-main { grid-template-rows: auto 1fr !important; }
  .topbar-marca { display: block; flex: none; }
  .topbar-marca img { display: block; width: 34px; height: 34px; object-fit: contain; }
  .topbar-titulo { display: block; flex: 1; min-width: 0; margin: 0; font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar .crumb, .topbar .search-kbd, .topbar .topbar-actions > button[title="Atualizar"] { display: none !important; }
  /* Fora do Painel a busca global fica recolhida num ícone e abre ao tocar. */
  .topbar .search-wrap { flex: 0 0 44px; width: 44px; min-width: 0; height: 44px; margin: 0; position: static; }
  .topbar .search-wrap .search-input { width: 44px; height: 44px; padding: 0 0 0 44px; border-radius: 12px; color: transparent; background: transparent; border-color: transparent; cursor: pointer; }
  .topbar .search-wrap .search-input::placeholder { color: transparent; }
  .topbar .search-wrap .search-icon { left: 14px; pointer-events: none; }
  .topbar .search-wrap:focus-within { position: absolute; left: 12px; right: 12px; top: 6px; width: auto; z-index: 5; }
  .topbar .search-wrap:focus-within .search-input { width: 100%; padding-left: 40px; color: inherit; background: #fff; border-color: var(--line-strong, #d8cbb6); cursor: text; }
  .topbar .search-wrap:focus-within .search-input::placeholder { color: #9a8f80; }
  .topbar { position: sticky; }
  .topbar-actions { margin-left: auto; }
  .topbar-actions .icon-btn { width: 44px; height: 44px; }
  /* No Painel a busca global vira um campo grande abaixo do topo */
  .topbar[data-pagina="dashboard"] { flex-wrap: wrap; height: auto; padding-bottom: 10px !important; }
  .topbar[data-pagina="dashboard"] .search-wrap, .topbar[data-pagina="dashboard"] .search-wrap:focus-within { order: 9; flex: 1 1 100%; width: auto; height: auto; max-width: none; margin: 0; position: relative; left: auto; right: auto; top: auto; }
  .topbar[data-pagina="dashboard"] .search-wrap .search-input { width: 100%; height: 48px; padding-left: 40px; font-size: 16px; color: inherit; background: #fff; border-color: var(--line-strong, #d8cbb6); cursor: text; }
  .topbar[data-pagina="dashboard"] .search-wrap .search-input::placeholder { color: #9a8f80; }

  /* Conteúdo */
  .app-content, .app-main > main, main.app-content { padding-left: 12px !important; padding-right: 12px !important; }
  .page-title, .crm-hero-title { font-size: 22px !important; }
  .card, .crm-card { border-radius: 14px; }
  /* Animação com transform prenderia os elementos fixos (folhas, botões) dentro do cartão. */
  .crm-fade-in { animation: none !important; transform: none !important; opacity: 1 !important; }
  .row { --bs-gutter-x: 12px; }

  /* KPIs: 2 colunas; o primeiro ocupa a linha toda, escuro */
  .metric-grid, .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px !important; }
  .metric-grid > :first-child, .kpi-row > :first-child { grid-column: 1 / -1; background: #3a2414 !important; border-color: #3a2414 !important; color: #f4e9d8; }
  .metric-grid > :first-child .metric-value, .metric-grid > :first-child .crm-metric-value, .kpi-row > :first-child .metric-value, .kpi-row > :first-child .crm-metric-value { color: #f2c879 !important; }
  .metric-grid > :first-child .metric-label, .metric-grid > :first-child .crm-metric-label, .kpi-row > :first-child .metric-label, .kpi-row > :first-child .crm-metric-label, .metric-grid > :first-child .metric-foot, .kpi-row > :first-child .metric-foot { color: #d9c7ad !important; }

  /* Tabelas viram cartões */
  table.crm-tabela-cartoes, table.crm-tabela-cartoes tbody { display: block; width: 100%; }
  table.crm-tabela-cartoes thead { display: none; }
  table.crm-tabela-cartoes tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; margin: 0 0 10px; padding: 12px 14px; border: 1px solid rgba(58, 36, 20, .12); border-radius: 12px; background: #fff; }
  table.crm-tabela-cartoes td { display: block; padding: 0 !important; border: 0 !important; min-width: 0; overflow-wrap: anywhere; text-align: left !important; font-size: 14px; color: #6b6052; }
  table.crm-tabela-cartoes td:first-child { grid-column: 1; font-weight: 700; font-size: 15px; color: #1d1813; }
  table.crm-tabela-cartoes td:nth-child(2) { grid-column: 2; grid-row: 1; text-align: right !important; font-weight: 600; color: #1d1813; }
  table.crm-tabela-cartoes td:nth-child(n+3) { grid-column: 1 / -1; }
  table.crm-tabela-cartoes td:nth-child(n+3)[data-rotulo]::before { content: attr(data-rotulo) ": "; color: #9a8f80; }
  .table-shell, .crm-table-shell, .table-wrap, .table-responsive { overflow: visible !important; border: 0 !important; background: none !important; box-shadow: none !important; }

  /* Formulários */
  .crm-input, .input, .form-control, .form-select, input[type="text"], input[type="search"], input[type="password"], input[type="email"], input[type="number"], input[type="date"], input[type="tel"], select, textarea { font-size: 16px !important; }
  .crm-input, .input, .form-control, .form-select, .app input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), .app select { min-height: 44px; }
  .btn, .crm-btn, .app button { min-height: 44px; }
  .crm-toolbar { flex-wrap: wrap; gap: 8px; }
  .crm-toolbar > * { flex: 1 1 100%; }
  .row > [class*="col-md-"], .row > [class*="col-lg-"], .row > [class*="col-sm-"] { flex: 0 0 100%; max-width: 100%; }
  .row > .col-6, .row > [class*="col-md-3"]:has(input[type="date"]), .row > [class*="col-md-2"]:has(input[type="date"]) { flex: 0 0 50%; max-width: 50%; }

  /* Abas em controle segmentado */
  .nav-tabs, .nav-pills, .modal-tabs, .crm-abas { display: flex; flex-wrap: nowrap; gap: 4px; padding: 4px; border: 0 !important; border-radius: 12px; background: #e4dccf; overflow-x: auto; }
  .nav-tabs .nav-link, .nav-pills .nav-link, .modal-tab { flex: 1 0 auto; min-height: 40px; border: 0 !important; border-radius: 9px !important; background: none; color: #5a4f43; font-weight: 600; text-align: center; white-space: nowrap; }
  .nav-tabs .nav-link.active, .nav-pills .nav-link.active, .modal-tab.is-active, .modal-tab.active { background: #fff !important; color: #1d1813 !important; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

  /* Modais viram folha de baixo */
  .modal-dialog { position: fixed; left: 0; right: 0; bottom: 0; margin: 0 !important; max-width: none !important; width: 100% !important; }
  .modal-content { border: 0; border-radius: 18px 18px 0 0 !important; max-height: 92dvh; overflow-y: auto; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .modal { padding: 0 !important; }
  .modal-back + .modal, .modal-back .modal { position: fixed; left: 0; right: 0; bottom: 0; width: 100% !important; max-width: none !important; max-height: 92dvh; overflow-y: auto; border-radius: 18px 18px 0 0; }

  /* Barra de ação fixa acima da navegação (páginas marcam o botão com data-acao-fixa) */
  body.crm-com-acao { --crm-acao-h: 68px; }
  [data-acao-fixa].crm-acao-fixa-on { position: fixed; left: 12px; right: 12px; bottom: calc(var(--crm-bnav-h) + 10px); z-index: 1030; width: auto !important; min-height: 50px; margin: 0 !important; box-shadow: 0 6px 18px rgba(29, 24, 19, .25); }

  /* Filtros em folha de baixo */
  .crm-filtros-botao { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px; margin: 4px 0 10px; border: 1px solid rgba(58, 36, 20, .2); border-radius: 999px; background: #fff; color: #1d1813; font-weight: 600; }
  .crm-filtros-bloco:not(.crm-filtros-on) { display: none !important; }
  .crm-filtros-on { display: grid !important; grid-template-columns: 1fr !important; gap: 10px !important; position: fixed !important; left: 0; right: 0; bottom: 0; z-index: 1046; max-height: 86dvh; overflow-y: auto; margin: 0 !important; padding: 18px 16px calc(16px + env(safe-area-inset-bottom, 0px)) !important; border-radius: 18px 18px 0 0; background: #fff; box-shadow: 0 -10px 30px rgba(0, 0, 0, .25); }
  .crm-filtros-ver { display: block; min-height: 50px; border: 0; border-radius: 12px; background: #b78a2b; color: #fff; font-weight: 700; }
  body.crm-filtros-aberto .crm-filtros-fundo { display: block; position: fixed; inset: 0; z-index: 1045; background: rgba(29, 24, 19, .45); }
  /* Folha ou janela aberta: o fundo não rola e a rolagem de dentro não "vaza" para a página de trás. */
  body.crm-filtros-aberto { overflow: hidden; }
  .crm-filtros-on, .crm-mais, .modal-content, .modal-back + .modal, .modal-back .modal { overscroll-behavior: contain; }

  /* Toasts acima da barra inferior */
  .toast-stack { bottom: calc(var(--crm-bnav-h) + 12px) !important; }
}

/* Página do CRM aberta dentro do caixa (?embed=caixa): sem a navegação do CRM. */
html.crm-embed .sidebar, html.crm-embed .topbar, html.crm-embed .crm-bnav, html.crm-embed .mobile-menu-backdrop { display: none !important; }
html.crm-embed .app { grid-template-columns: 1fr !important; }
html.crm-embed .app-main { grid-template-rows: 1fr !important; }
html.crm-embed body { padding-bottom: 0 !important; }
