/* ============================================================================
   Xtreme Motors — Design System
   Server-rendered, zero-build. Tokens + atomic components.
   Sistema interno de concessionária: vermelho/preto, compacto, alto contraste.
   Light + dark, 8pt grid.
   ============================================================================ */

/* ---- 1. Design tokens ---------------------------------------------------- */
:root {
  /* Brand (vermelho) */
  --accent:            #d32f2f;
  --accent-hover:      #b71c1c;
  --accent-active:     #9a1616;
  --accent-soft:       #fdecec;
  --accent-contrast:   #ffffff;

  /* Neutros (light) — cinza levemente frio, bordas definidas */
  --canvas:            #f2f3f5;
  --surface:           #ffffff;
  --surface-2:         #eceef1;
  --surface-hover:     #f1f2f4;
  --border:            #d9dce1;
  --border-strong:     #c3c7ce;

  --text:              #16181d;
  --text-secondary:    #565b64;
  --text-tertiary:     #868c96;

  /* Semantic */
  --success:           #167c48; --success-soft: #e2f3e9;
  --danger:            #d32f2f; --danger-hover: #b71c1c; --danger-soft: #fdecec;
  --warning:           #a86a00; --warning-soft: #fbefd9;
  --info:              #1a73e8; --info-soft: #e0edff;

  /* Sidebar (escura mesmo no tema claro — cara de ERP) */
  --sidebar-bg:        #17181b;
  --sidebar-fg:        #eceef1;
  --sidebar-fg-muted:  #9aa0aa;
  --sidebar-border:    #2a2c31;
  --sidebar-hover:     #232529;
  --sidebar-active-bg: rgba(211,47,47,.16);
  --sidebar-active-fg: #ff6a5f;

  /* Radii — menores, mais utilitário */
  --r-sm:   3px;
  --r:      5px;
  --r-md:   6px;
  --r-lg:   11px;
  --r-full: 999px;

  /* Shadows — discretas, planas */
  --shadow-sm:  0 1px 1px rgba(16,18,22,.05);
  --shadow:     0 1px 2px rgba(16,18,22,.07);
  --shadow-md:  0 2px 6px rgba(16,18,22,.10);
  --shadow-lg:  0 8px 24px rgba(16,18,22,.16), 0 2px 6px rgba(16,18,22,.08);
  --ring:       0 0 0 3px color-mix(in srgb, var(--accent) 26%, transparent);

  /* Typography */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;

  /* Spacing (8pt grid) */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 48px;

  --sidebar-w: 220px;
  --content-max: 2000px;
  --topbar-h: calc(var(--s-3) * 2 + 34px + 1px);
}

/* Dark tokens. base.html sets data-theme="light"|"dark" inline before first
   paint (from localStorage, defaulting to "light"), so data-theme is always
   explicit — a prefers-color-scheme fallback here would never be reachable. */
:root[data-theme="dark"] {
  --accent:#f05545; --accent-hover:#f26b5c; --accent-active:#f47f72;
  --accent-soft:#2a1613; --accent-contrast:#ffffff;
  --canvas:#0c0d0f; --surface:#16181b; --surface-2:#1d1f23; --surface-hover:#22242a;
  --border:#2a2c31; --border-strong:#383b42;
  --text:#eef0f3; --text-secondary:#9aa0aa; --text-tertiary:#6b7079;
  --success:#3dd68c; --success-soft:#10231a;
  --danger:#f0685a; --danger-hover:#f27f72; --danger-soft:#2a1613;
  --warning:#e0a832; --warning-soft:#251d0f;
  --info:#8ab4f8; --info-soft:#1a2335;
  --sidebar-bg:#101113; --sidebar-fg:#eef0f3; --sidebar-fg-muted:#7f858e;
  --sidebar-border:#24262b; --sidebar-hover:#1c1e22;
  --sidebar-active-bg:rgba(240,85,69,.16); --sidebar-active-fg:#ff8579;
  --shadow-sm:0 1px 2px rgba(0,0,0,.4);
  --shadow:0 1px 3px rgba(0,0,0,.5);
  --shadow-md:0 2px 6px rgba(0,0,0,.5);
  --shadow-lg:0 10px 28px rgba(0,0,0,.6),0 4px 8px rgba(0,0,0,.5);
}

/* ---- 2. Reset ------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv02","cv03","cv04","cv11";
}
h1,h2,h3,h4 { line-height: 1.25; font-weight: 650; letter-spacing: -0.012em; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; }
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }
::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }

/* ---- 3. App shell -------------------------------------------------------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100dvh; }

.sidebar {
  position: sticky; top: 0; align-self: start;
  height: 100dvh; display: flex; flex-direction: column;
  gap: var(--s-2); padding: var(--s-3);
  background: var(--sidebar-bg); color: var(--sidebar-fg);
  border-right: 1px solid var(--sidebar-border);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.sidebar__brand {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-2) var(--s-2) var(--s-4);
  font-weight: 700; font-size: .95rem; letter-spacing: -.01em;
  color: var(--sidebar-fg);
}
/* Shared "icon badge" primitive: centers an icon/glyph inside a fixed box.
   Size, radius, background and color stay per-component; this only covers
   the centering layout that was previously repeated on each of them. */
.sidebar__logo, .avatar, .action-card__icon, .connection-status__icon,
.empty__icon, .auth__logo-icon, .mmgr__drop-icon {
  display: grid; place-items: center; flex: none;
}
.sidebar__logo {
  width: 30px; height: 30px; border-radius: var(--r);
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-active));
  box-shadow: var(--shadow-sm);
}
.sidebar__logo--sm { width: 26px; height: 26px; }
.sidebar__user form { margin-left: auto; }
.sidebar__section {
  font-size: .66rem; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--sidebar-fg-muted);
  padding: var(--s-8) var(--s-2) var(--s-1);
}
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav__link {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 7px var(--s-3); border-radius: var(--r);
  color: var(--sidebar-fg-muted); font-weight: 500;
  transition: background .12s, color .12s;
}
.nav__link:hover { background: var(--sidebar-hover); color: var(--sidebar-fg); text-decoration: none; }
.nav__link.is-active { background: var(--sidebar-active-bg); color: var(--sidebar-active-fg); font-weight: 600; }
.nav__link svg { width: 17px; height: 17px; flex: none; }
.sidebar__footer { margin-top: auto; display: flex; flex-direction: column; gap: var(--s-2); }
.sidebar__user {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-2) var(--s-2); border-top: 1px solid var(--sidebar-border);
  padding-top: var(--s-3);
}
.sidebar__user-link {
  flex: 1;
  min-width: 0;
  text-decoration: none;
}
/* Botões dentro da sidebar escura */
.sidebar .btn--ghost { color: var(--sidebar-fg-muted); }
.sidebar .btn--ghost:hover { background: var(--sidebar-hover); color: var(--sidebar-fg); }
.sidebar .icon-btn {
  background: transparent; border-color: var(--sidebar-border); color: var(--sidebar-fg-muted);
}
.sidebar .icon-btn:hover { background: var(--sidebar-hover); color: var(--sidebar-fg); }
.avatar {
  width: 30px; height: 30px; border-radius: var(--r-full);
  font-size: .75rem; font-weight: 700;
  background: rgba(255,255,255,.08); color: var(--sidebar-fg);
}
.sidebar__user-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.sidebar__user-meta b { font-weight: 600; font-size: .82rem; color: var(--sidebar-fg); }
.sidebar__user-meta span { font-size: .72rem; color: var(--sidebar-fg-muted); }

/* ---- 4. Topbar (mobile only) --------------------------------------------- */
.topbar {
  display: none; position: sticky; top: 0; z-index: 30;
  align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar__brand { display: flex; align-items: center; gap: var(--s-2); font-weight: 700; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px;
  border-radius: var(--r); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text-secondary); cursor: pointer;
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

/* ---- 5. Content ---------------------------------------------------------- */
.content { min-width: 0; }
.content__inner { max-width: var(--content-max); margin: 0 auto; padding: var(--s-6) var(--s-4) var(--s-10); }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--s-4); margin-bottom: var(--s-5); flex-wrap: wrap;
  padding-bottom: var(--s-4); border-bottom: 1px solid var(--border);
}
.page-head__title h1 { margin-bottom: 2px; }
.page-head__subtitle { color: var(--text-secondary); font-size: .84rem; }
.page-head__actions { display: flex; gap: var(--s-3); flex-wrap: wrap; }
.dashboard-filter { display: flex; align-items: center; gap: var(--s-2); }
.dashboard-filter .select { min-width: 132px; }

/* ---- 6. Buttons ---------------------------------------------------------- */
.btn {
  --_bg: var(--surface); --_fg: var(--text); --_bd: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  height: 32px; padding: 0 var(--s-3); border-radius: var(--r);
  font-size: .82rem; font-weight: 550; white-space: nowrap; cursor: pointer;
  background: var(--_bg); color: var(--_fg); border: 1px solid var(--_bd);
  box-shadow: var(--shadow-sm);
  transition: background .12s, border-color .12s, box-shadow .12s, transform .06s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(.5px); }
.btn svg { width: 16px; height: 16px; }
.btn--primary {
  --_bg: var(--accent); --_fg: var(--accent-contrast); --_bd: transparent;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,.14);
  font-weight: 600;
}
.btn--primary:hover { --_bg: var(--accent-hover); }
.btn--primary:active { --_bg: var(--accent-active); }
.btn--ghost { --_bg: transparent; --_bd: transparent; box-shadow: none; color: var(--text-secondary); }
.btn--ghost:hover { --_bg: var(--surface-hover); color: var(--text); }
.btn--default:hover { --_bg: var(--surface-hover); }
.btn--danger { --_fg: var(--danger); }
.btn--danger-fill { --_bg: var(--danger); --_bd: transparent; }
.btn--danger-fill:hover { --_bg: var(--danger-hover); }
.btn--info {
  --_bg: var(--info); --_fg: #fff; --_bd: transparent;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,.14);
  font-weight: 600;
}
.btn--info:hover { --_bg: color-mix(in srgb, var(--info) 88%, #000); }
.btn--info:active { --_bg: color-mix(in srgb, var(--info) 78%, #000); }
.btn--sm { height: 28px; padding: 0 var(--s-2); font-size: .78rem; }
.btn--block { width: 100%; height: 38px; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.action-edit { color: var(--success); }
.action-delete { color: var(--danger); }
.action-cash { color: var(--info); }
.action-file { color: var(--warning); }
.action-view { color: var(--warning); }
.action-file--purple { color: #7c3aed; }
.action-image { color: #0891b2; }
.action-user { color: #4f46e5; }

/* ---- 7. Forms ------------------------------------------------------------ */
.field { display: flex; flex-direction: column; gap: 5px; }
.field__label { font-size: .78rem; font-weight: 550; color: var(--text-secondary); }
.input, .select, textarea.input {
  width: 100%; height: 34px; padding: 0 var(--s-3);
  font-size: .85rem; font-family: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r); transition: border-color .12s, box-shadow .12s;
  appearance: none;
}
textarea.input { height: auto; padding: var(--s-2) var(--s-3); }
.input::placeholder { color: var(--text-tertiary); }
.input:focus, .select:focus { border-color: var(--accent); box-shadow: var(--ring); outline: none; }
.input:hover, .select:hover { border-color: var(--border-strong); }
.input.rsd-field--filled { border-color: var(--success); }
.input.rsd-field--conflict { border-color: var(--warning); }
.rsd-apply { margin-left: var(--s-2); }
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23868c96' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right var(--s-3) center;
  padding-right: var(--s-8); cursor: pointer;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
.form-grid .field--full { grid-column: 1 / -1; }
.form-grid--full { grid-column: 1 / -1; }
.form-grid__divider { grid-column: 1 / -1; border: 0; border-top: 1px solid var(--border); margin: var(--s-2) 0; }

/* Search */
.search { position: relative; flex: 1.4; min-width: 200px; }
.search svg {
  position: absolute; left: var(--s-3); top: 50%; transform: translateY(-50%);
  width: 17px; height: 17px; color: var(--text-secondary); pointer-events: none;
  transition: color .12s;
}
.search .input { padding-left: var(--s-8); height: 36px; }
.search .input:focus ~ svg { color: var(--accent); }

/* Search + Filter group */
.search-filter-group {
  display: flex; align-items: center; gap: var(--s-3); flex: 1; min-width: 0;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--s-2);
  box-shadow: var(--shadow-sm); transition: border-color .12s, box-shadow .12s;
}
.search-filter-group:focus-within { border-color: var(--accent); box-shadow: var(--shadow-md); }

.filter-separator {
  width: 1px; height: 20px; background: var(--border); flex: none;
}

.filter-control {
  display: flex; align-items: center; gap: var(--s-2); flex: 1; min-width: 160px;
}
.filter-label {
  display: flex; align-items: center; gap: 4px;
  font-size: .76rem; font-weight: 550; color: var(--text-secondary);
  white-space: nowrap; flex: none;
}
.filter-label svg { width: 14px; height: 14px; color: var(--text-tertiary); }

.filter-select {
  flex: 1; min-width: 100px; border: none !important; box-shadow: none !important;
  background: transparent !important; padding: 0 var(--s-2) !important;
  height: auto !important; font-size: .82rem;
}
.filter-select:focus { background: transparent !important; }

.filter-badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: var(--r-full);
  font-size: .7rem; font-weight: 650; background: var(--accent-soft);
  color: var(--accent); white-space: nowrap; flex: none;
  text-transform: uppercase; letter-spacing: .03em;
}

/* Filter bar */
.filter-bar { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.filter-bar .input { height: 36px; width: auto; }

/* ---- 8. Card ------------------------------------------------------------- */
.card {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
  transition: box-shadow .15s, transform .15s;
  min-width: 0;
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.card--pad { padding: var(--s-5); }
.dashboard-section { margin-top: var(--s-6); }
.dashboard-section__title { margin-bottom: var(--s-4); }
.card--pad > h2 { display: flex; align-items: center; gap: var(--s-2); font-size: 1.2rem; margin-bottom: var(--s-8); color: var(--text); font-weight: 900; }
.card--pad > h2 svg { width: 20px; height: 20px; flex: none; }
.panel-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-4); align-items: stretch; margin-bottom: var(--s-4); }
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-4); margin-bottom: var(--s-4); flex-wrap: wrap;
}
.toolbar > .search-filter-group { flex: 1; min-width: 320px; }
.paginacao { margin-top: var(--s-4); }
.paginacao__nav { display: flex; gap: var(--s-2); }

/* ---- 9. Stat cards ------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--s-3); margin-bottom: var(--s-5); }
.stat { padding: var(--s-4); }
.stat__label { display: flex; align-items: center; gap: var(--s-2); font-size: .76rem; color: var(--text-secondary); font-weight: 550; }
.stat__label svg { width: 15px; height: 15px; color: var(--text-tertiary); }
.stat__value { font-size: 1.4rem; font-weight: 700; letter-spacing: -.02em; margin-top: var(--s-1); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat__hint { font-size: .74rem; color: var(--text-tertiary); margin-top: 2px; overflow-wrap: anywhere; }

.stat--accent { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 28%, transparent); }
.stat--accent .stat__label svg { color: var(--accent); }
.stat--accent .stat__value { color: var(--accent); }

.stat--success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 28%, transparent); }
.stat--success .stat__label svg { color: var(--success); }
.stat--success .stat__value { color: var(--success); }

.stat--warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 28%, transparent); }
.stat--warning .stat__label svg { color: var(--warning); }
.stat--warning .stat__value { color: var(--warning); }

.stat--info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 28%, transparent); }
.stat--info .stat__label svg { color: var(--info); }
.stat--info .stat__value { color: var(--info); }

.stat--cost { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 28%, transparent); }
.stat--cost .stat__label svg { color: var(--danger); }
.stat--cost .stat__value { color: var(--danger); }

/* ---- 10. Table ----------------------------------------------------------- */
.table-wrap { position: relative; max-height: calc(100dvh - 220px); overflow: auto; border-radius: var(--r-lg); border: 1px solid var(--border); background: var(--surface-2); }
table { width: 100%; border-collapse: collapse; font-size: .83rem; }
thead th {
  text-align: left; font-weight: 650; font-size: .7rem; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-secondary);
  padding: var(--s-2) var(--s-3); background: var(--surface-2);
  border-bottom: 1px solid var(--border-strong); white-space: nowrap;
  position: sticky; top: 0; z-index: 2;
}
tbody td { padding: 6px var(--s-3); border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--surface-hover); }
.cell-strong { font-weight: 600; color: var(--text); }
.cell-mono { font-family: var(--font-mono); font-size: .8rem; color: var(--text-secondary); white-space: nowrap; }
.cell-num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.table--wide { min-width: 900px; }
.row-actions { display: flex; gap: var(--s-1); justify-content: flex-end; }
th.col-actions, td.col-actions {
  text-align: right; width: 1%; white-space: nowrap;
  position: sticky; right: 0;
}
th.col-actions { z-index: 3; }
td.col-actions { background: var(--surface-2); z-index: 1; }
.cell-check { width: 15px; height: 15px; color: var(--success); vertical-align: middle; }

/* ---- 11. Badge ----------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: var(--s-1);
  padding: 2px 8px; border-radius: var(--r-sm);
  font-size: .72rem; font-weight: 600; line-height: 1.4; white-space: nowrap;
  background: var(--surface-2); color: var(--text-secondary);
  border: 1px solid var(--border);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: var(--r-full); background: currentColor; }
.badge--success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge--danger  { background: var(--danger-soft);  color: var(--danger);  border-color: transparent; }
.badge--neutral { background: var(--surface-2); color: var(--text-secondary); }
.badge--accent  { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge--info    { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge--warning { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge--plain::before { display: none; }
.badge--noninteractive { opacity: .62; cursor: not-allowed; }

/* ---- 12. Modal ----------------------------------------------------------- */
dialog {
  border: none; padding: 0; background: transparent; color: inherit;
  max-width: 100%; max-height: 100%;
}
dialog::backdrop { background: rgba(10,11,13,.5); backdrop-filter: blur(2px); }
.modal {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center; padding: var(--s-4);
  background: rgba(10,11,13,.5); backdrop-filter: blur(2px);
  animation: fade .15s ease;
}
.modal__panel {
  width: 100%; max-width: 560px; max-height: 90dvh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  animation: pop .16s cubic-bezier(.16,1,.3,1);
}
.modal__panel--sm { max-width: 400px; }
.modal__panel--lg { max-width: 900px; }
.modal__head { display: flex; align-items: center; justify-content: space-between; padding: var(--s-4) var(--s-4) var(--s-3); border-bottom: 1px solid var(--border); }
.modal__head h3 { font-size: 1rem; }
.modal__body { padding: var(--s-4); display: flex; flex-direction: column; gap: var(--s-3); }
.modal__body--pad-top { padding-top: var(--s-5); }
#confirm-dialog-q { white-space: pre-line; }
.modal__section { font-size: .82rem; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .04em; }
.modal__foot { display: flex; justify-content: flex-end; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.wizard-steps { font-size: .78rem; font-weight: 550; color: var(--text-secondary); }
.wizard-step { display: none; border: 0; margin: 0; padding: 0; min-width: 0; }
.wizard-step.is-active { display: grid; }
.rsd-actions--inline { align-self: end; }
.rsd-actions--inline .btn { height: 34px; padding: 0 var(--s-3); font-size: .85rem; }
.rsd-actions--inline > .rsd-status { margin-top: 0; min-height: 1.1rem; }

/* Wizard modal — larger panel & fields */
.modal__panel--wizard {
  max-width: 600px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal__panel--wizard > form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
}
.modal__panel--wizard > form > .modal__body {
  min-height: 0;
  overflow-y: auto;
}
.modal__panel--wizard .field__label { font-size: .82rem; }
.modal__panel--wizard .input,
.modal__panel--wizard .select,
.modal__panel--wizard textarea.input { height: 40px; font-size: .9rem; }
.modal__panel--wizard textarea.input { height: auto; padding: var(--s-3); }
.modal__panel--wizard .form-grid { gap: var(--s-4); }
.modal__panel--wizard .select {
  appearance: auto;
  -webkit-appearance: menulist-button;
  background-image: none;
  padding-right: var(--s-3);
}
.modal__panel--wizard .input[list] {
  appearance: auto;
  -webkit-appearance: auto;
}

/* Stepper */
.stepper { display: flex; align-items: flex-start; margin-bottom: var(--s-2); }
.stepper__item { display: flex; flex-direction: column; align-items: center; gap: var(--s-2); flex: 1; text-align: center; position: relative; }
.stepper__connector { flex: 1; height: 2px; background: var(--border-strong); margin-top: 15px; }
.stepper__connector.is-done { background: var(--accent); }
.stepper__num {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-full);
  border: 2px solid var(--border-strong); color: var(--text-secondary);
  font-size: .82rem; font-weight: 650; background: var(--surface);
  transition: background .12s, border-color .12s, color .12s;
}
.stepper__num svg { width: 16px; height: 16px; }
.stepper__label { font-size: .76rem; font-weight: 550; color: var(--text-tertiary); }
.stepper__item.is-active .stepper__num { border-color: var(--accent); color: var(--accent); }
.stepper__item.is-active .stepper__label { color: var(--text); }
.stepper__item.is-done .stepper__num { border-color: var(--accent); background: var(--accent); color: var(--accent-contrast); }
.stepper__item.is-done .stepper__label { color: var(--text-secondary); }
.details-list { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-6); margin: 0; }
.details-list div { min-width: 0; }
.details-list dt { font-size: .86rem; font-weight: 800; color: var(--text-secondary); text-transform: uppercase; }
.details-list dd { margin: 4px 0 0; color: var(--text); overflow-wrap: anywhere; font-size: .95rem; }
.panel-grid .details-list dd { color: var(--success); }
.modal-section { display: flex; flex-direction: column; gap: var(--s-2); }
.modal-section h4 { font-size: .88rem; }

/* Fechamento de venda */
.fechamento-hero { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: var(--s-2) 0 var(--s-1); text-align: center; }
.fechamento-hero__label { font-size: .78rem; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .04em; }
.fechamento-hero__value { font-size: 1.9rem; font-weight: 800; letter-spacing: -.02em; }
.fechamento-hero__value--positive { color: var(--success); }
.fechamento-hero__value--negative { color: var(--danger); }
.fechamento-hero__date { font-size: .78rem; color: var(--text-tertiary); }

.fechamento-rows { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; margin: 0; }
.fechamento-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-3) var(--s-4); font-size: .88rem; }
.fechamento-row + .fechamento-row { border-top: 1px solid var(--border); }
.fechamento-row dt { color: var(--text-secondary); font-weight: 500; }
.fechamento-row dd { margin: 0; font-weight: 650; color: var(--text); }

.fechamento-participacoes { display: flex; flex-direction: column; gap: var(--s-2); }
.fechamento-investidor { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.fechamento-investidor__avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-full); background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .85rem; flex: none; }
.fechamento-investidor__info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.fechamento-investidor__nome { font-weight: 600; font-size: .88rem; }
.fechamento-investidor__pct { font-size: .78rem; color: var(--text-secondary); }
.fechamento-investidor__valor { font-weight: 700; font-size: .9rem; }

.fechamento-rateio { display: flex; flex-direction: column; }
.fechamento-rateio__field { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) 0; }
.fechamento-rateio__field + .fechamento-rateio__field { border-top: 1px solid var(--border); }
.fechamento-rateio__nome { flex: 1; min-width: 0; font-size: .88rem; font-weight: 550; }
.fechamento-rateio__input-wrap { position: relative; flex: none; width: 110px; }
.fechamento-rateio__input-wrap .input { padding-right: 26px; text-align: right; }
.fechamento-rateio__input-wrap::after { content: "%"; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--text-tertiary); font-size: .85rem; pointer-events: none; }

.fechamento-total-chip { display: inline-flex; align-items: center; gap: 4px; margin-top: var(--s-3); padding: 6px var(--s-3); border-radius: var(--r-full); font-size: .82rem; font-weight: 650; background: var(--surface-2); color: var(--text-secondary); transition: background .12s, color .12s; }
.fechamento-total-chip--valid { background: var(--success-soft); color: var(--success); }
.fechamento-total-chip--invalid { background: var(--danger-soft); color: var(--danger); }

/* ---- Página de configurações -------------------------------------------- */
.settings-tabs { display: flex; flex-direction: column; gap: var(--s-4); }
.settings-tabs__input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.settings-tabs__panel { display: none; flex-direction: column; gap: var(--s-4); min-width: 0; }
/* Um bloco por aba: junta painel + destaque do nav (label/ícone/título) num só
   lugar, evitando repetir os 5 ids de aba em 4 blocos separados. */
#tab-banco:checked ~ .settings-layout {
  .settings-tabs__panel--banco { display: flex; }
  .settings-nav label[for="tab-banco"] {
    background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 24%, transparent);
    .settings-nav__icon { background: var(--accent); color: var(--accent-contrast); }
    .settings-nav__title { color: var(--accent); }
  }
}
#tab-whatsapp:checked ~ .settings-layout {
  .settings-tabs__panel--whatsapp { display: flex; }
  .settings-nav label[for="tab-whatsapp"] {
    background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 24%, transparent);
    .settings-nav__icon { background: var(--accent); color: var(--accent-contrast); }
    .settings-nav__title { color: var(--accent); }
  }
}
#tab-telegram:checked ~ .settings-layout {
  .settings-tabs__panel--telegram { display: flex; }
  .settings-nav label[for="tab-telegram"] {
    background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 24%, transparent);
    .settings-nav__icon { background: var(--accent); color: var(--accent-contrast); }
    .settings-nav__title { color: var(--accent); }
  }
}
#tab-rsd:checked ~ .settings-layout {
  .settings-tabs__panel--rsd { display: flex; }
  .settings-nav label[for="tab-rsd"] {
    background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 24%, transparent);
    .settings-nav__icon { background: var(--accent); color: var(--accent-contrast); }
    .settings-nav__title { color: var(--accent); }
  }
}
#tab-tema:checked ~ .settings-layout {
  .settings-tabs__panel--tema { display: flex; }
  .settings-nav label[for="tab-tema"] {
    background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 24%, transparent);
    .settings-nav__icon { background: var(--accent); color: var(--accent-contrast); }
    .settings-nav__title { color: var(--accent); }
  }
}
#tab-empresa:checked ~ .settings-layout {
  .settings-tabs__panel--empresa { display: flex; }
  .settings-nav label[for="tab-empresa"] {
    background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 24%, transparent);
    .settings-nav__icon { background: var(--accent); color: var(--accent-contrast); }
    .settings-nav__title { color: var(--accent); }
  }
}

.settings-layout { display: grid; grid-template-columns: 240px 1fr; align-items: start; gap: var(--s-5); }

/* Vertical settings nav (Stripe/Vercel-style) */
.settings-nav {
  display: flex; flex-direction: column; gap: 2px;
  padding: var(--s-2); border: 1px solid var(--border);
  border-radius: var(--r-lg); background: var(--surface-2);
  box-shadow: var(--shadow-sm); position: sticky; top: var(--s-4);
}
.settings-nav__item {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-3); border-radius: var(--r-md);
  cursor: pointer; border: 1px solid transparent;
  transition: background .12s, border-color .12s;
}
.settings-nav__item:hover { background: var(--surface-hover); }
.settings-nav__item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.settings-nav__icon {
  display: grid; place-items: center; flex: none;
  width: 32px; height: 32px; border-radius: var(--r-md);
  background: var(--surface-2); color: var(--text-secondary);
  transition: background .12s, color .12s;
}
.settings-nav__icon svg { width: 17px; height: 17px; }
.settings-nav__text { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.settings-nav__title { display: flex; align-items: center; gap: var(--s-2); font-size: .86rem; font-weight: 600; color: var(--text); }
.settings-nav__desc { font-size: .74rem; color: var(--text-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.settings-nav__dot { width: 6px; height: 6px; border-radius: var(--r-full); background: var(--text-tertiary); flex: none; }
.settings-nav__dot--ok { background: var(--success); }

.settings-panel-head h2 { margin-bottom: 2px; }
.rsd-test-result-slot { min-height: 0; }
.rsd-test-result {
  display: flex; align-items: flex-start; gap: var(--s-2); padding: var(--s-3);
  border-radius: var(--r-md); font-size: .86rem;
}
.rsd-test-result svg { flex: none; width: 17px; height: 17px; margin-top: 1px; }
.rsd-test-result--success { color: var(--success); background: var(--success-soft); }
.rsd-test-result--error { color: var(--danger); background: var(--danger-soft); }
.rsd-test-progress { display: inline-flex; align-items: center; gap: var(--s-2); color: var(--text-secondary); font-size: .82rem; }
.rsd-test-progress svg { width: 15px; height: 15px; animation: spin .8s linear infinite; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); align-items: start; }

/* Action cards (export/import) */
.action-card { display: flex; flex-direction: column; gap: var(--s-2); }
.action-card h3 { font-size: .95rem; }
.action-card form { margin-top: var(--s-2); }
.action-card__icon {
  width: 40px; height: 40px;
  border-radius: var(--r-lg); margin-bottom: var(--s-1);
}
.action-card__icon svg { width: 20px; height: 20px; }
.action-card__icon--accent { background: var(--accent-soft); color: var(--accent); }
.action-card__icon--danger { background: var(--danger-soft); color: var(--danger); }
.action-card--danger { border-color: color-mix(in srgb, var(--danger) 26%, var(--border)); }

.callout {
  display: flex; align-items: flex-start; gap: var(--s-2);
  padding: var(--s-3); border-radius: var(--r-md);
  font-size: .8rem; line-height: 1.5;
}
.callout svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.callout--danger { background: var(--danger-soft); color: var(--danger); }
.rsd-status { margin-top: var(--s-2); display: flex; flex-direction: column; gap: var(--s-2); }
.rsd-status__actions { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; }

/* Connection status callout */
.connection-status {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-4); border-radius: var(--r-lg); border: 1px solid var(--border);
}
.connection-status__icon {
  width: 40px; height: 40px; border-radius: var(--r-full);
}
.connection-status__icon svg { width: 19px; height: 19px; }
.connection-status__text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.connection-status__text strong { font-size: .88rem; }
.connection-status__text span { font-size: .8rem; color: var(--text-secondary); line-height: 1.45; }
.connection-status__text code { word-break: break-all; }
.connection-status--ok { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 26%, transparent); }
.connection-status--ok .connection-status__icon { background: var(--success); color: var(--accent-contrast); }
.connection-status--pending { background: var(--surface-2); }
.connection-status--pending .connection-status__icon { background: var(--surface); color: var(--text-tertiary); border: 1px solid var(--border); }

.settings-form { display: flex; flex-direction: column; gap: var(--s-5); }
.settings-form .modal-section h4 { display: flex; align-items: center; gap: var(--s-2); }
.settings-form .modal-section h4 svg { width: 16px; height: 16px; color: var(--text-tertiary); flex: none; }
.settings-message { margin-top: 0; }
.settings-actions { align-items: flex-end; margin-top: var(--s-2); padding-top: var(--s-4); border-top: 1px solid var(--border); }
.settings-actions--split { display: flex; gap: var(--s-2); flex-wrap: wrap; }

/* Password visibility toggle */
.field-password { position: relative; display: block; }
.field-password .input { padding-right: var(--s-8); }
.field-password__toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center; width: 26px; height: 26px;
  border: 0; border-radius: var(--r-sm); background: transparent;
  color: var(--text-tertiary); cursor: pointer;
}
.field-password__toggle:hover { background: var(--surface-hover); color: var(--text); }
.field-password__toggle svg { width: 16px; height: 16px; }
.field-password__icon-hide { display: none; }
.field-password__toggle.is-visible .field-password__icon-show { display: none; }
.field-password__toggle.is-visible .field-password__icon-hide { display: block; }

/* Placeholder chips (insert into message template) */
.placeholder-chips { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-1); }
.placeholder-chip {
  font-family: var(--font-mono); font-size: .74rem; font-weight: 600;
  padding: 4px 10px; border-radius: var(--r-full);
  border: 1px solid var(--border-strong); background: var(--surface-2);
  color: var(--text-secondary); cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.placeholder-chip:hover { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }

/* ---- Configuração de colunas das tabelas -------------------------------- */
.col-hidden { display: none !important; }
.cols-hint { font-size: .78rem; color: var(--text-secondary); margin: 0; }
.cols-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.cols-list li { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2); border-radius: var(--r-md); border: 1px solid transparent; }
.cols-list li:hover { background: var(--surface-hover); }
.cols-list li.dragging { opacity: .5; border-color: var(--border); background: var(--surface-2); }
.cols-list__grip { display: inline-flex; width: 18px; height: 18px; color: var(--text-tertiary); cursor: grab; flex: none; }
.cols-list__grip svg { width: 18px; height: 18px; }
.cols-list__label { display: flex; align-items: center; gap: var(--s-2); flex: 1; min-width: 0; cursor: pointer; }

/* ---- 13. Alert / inline messages ---------------------------------------- */
.alert {
  display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-2) var(--s-3); border-radius: var(--r);
  font-size: .84rem; background: var(--danger-soft); color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 22%, transparent);
  margin-bottom: var(--s-4);
}
.alert svg { width: 16px; height: 16px; flex: none; }
.alert--success {
  background: var(--success-soft); color: var(--success);
  border-color: color-mix(in srgb, var(--success) 22%, transparent);
}

/* ---- 14. Toast (#msg, oob-swapped) --------------------------------------- */
#msg:empty { display: none; }
#msg {
  position: fixed; right: var(--s-5); bottom: var(--s-5); z-index: 80;
  display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-3) var(--s-4); border-radius: var(--r-md);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg);
  font-size: .84rem; max-width: 360px;
  border-left: 3px solid var(--border-strong);
  animation: toast-in .25s cubic-bezier(.16,1,.3,1);
}
#msg svg { width: 16px; height: 16px; flex: none; }
#msg.toast--success { border-left-color: var(--success); }
#msg.toast--success svg { color: var(--success); }
#msg:has(.alert) { border-left-color: var(--danger); }
#msg:has(.alert) svg { color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }

/* ---- 15. Empty state ----------------------------------------------------- */
.empty { text-align: center; padding: var(--s-10) var(--s-6); color: var(--text-secondary); }
.empty__icon {
  width: 44px; height: 44px; margin: 0 auto var(--s-3);
  border-radius: var(--r-lg);
  background: var(--surface-2); color: var(--text-tertiary);
}
.empty__icon svg { width: 22px; height: 22px; }
.empty h3 { margin-bottom: var(--s-1); color: var(--text); }
.empty p { max-width: 340px; margin: 0 auto var(--s-4); font-size: .84rem; }

/* ---- 16. Auth screen ----------------------------------------------------- */
.auth {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--s-6);
  background-color: #0c0d0f;
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(240, 85, 69, 0.22), transparent),
    radial-gradient(circle at 10% 90%, rgba(240, 85, 69, 0.08), transparent 40%),
    radial-gradient(circle at 90% 20%, rgba(255, 255, 255, 0.03), transparent 30%);
  background-attachment: fixed;
}
.auth__card {
  width: 100%;
  max-width: 380px;
  padding: var(--s-8);
  box-shadow: var(--shadow-md);
}
.auth__brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  justify-content: center;
  margin-bottom: var(--s-4);
}
.auth__brand b { font-size: 1.05rem; font-weight: 700; }
.auth__logo {
  max-height: 60px;
  max-width: 220px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.08));
}
.auth__logo-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--r-md);
  background: var(--accent);
  color: var(--accent-contrast);
}
.auth__logo-icon svg { width: 20px; height: 20px; }
.auth__title { text-align: center; margin-bottom: var(--s-6); }
.auth__title p { color: var(--text-secondary); font-size: .84rem; margin-top: var(--s-1); }
.auth form { display: flex; flex-direction: column; gap: var(--s-4); }

/* ---- 17. Utilities ------------------------------------------------------- */
.stack { display: flex; flex-direction: column; gap: var(--s-4); }
.muted { color: var(--text-secondary); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
/* Esconde o markup controlado por x-show até o Alpine inicializar; sem isto
   todos os passos do wizard piscam visíveis no primeiro paint. */
[x-cloak] { display: none !important; }

/* ---- 18. Responsive ------------------------------------------------------ */
.scrim { display: none; }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .topbar { display: flex; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 50; width: 250px;
    transform: translateX(-100%); transition: transform .22s cubic-bezier(.16,1,.3,1);
    box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(10,11,13,.5); }
  .content__inner { padding: var(--s-4) var(--s-3) var(--s-8); }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head .btn { align-self: flex-start; }
  .stats { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .panel-grid { grid-template-columns: 1fr; }
  .settings-layout { grid-template-columns: 1fr; }
  .settings-tabs { gap: var(--s-3); }
  .settings-nav {
    position: sticky; top: calc(48px + var(--s-2)); z-index: 5;
    flex-direction: row; gap: var(--s-1); overflow-x: auto;
    margin-inline: calc(var(--s-3) * -1); padding: var(--s-2) var(--s-3);
    border-inline: 0; border-radius: 0; box-shadow: var(--shadow);
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .settings-nav::-webkit-scrollbar { display: none; }
  .settings-nav__item { flex: 0 0 auto; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-3); }
  .settings-nav__icon { width: 26px; height: 26px; border-radius: var(--r); }
  .settings-nav__icon svg { width: 15px; height: 15px; }
  .settings-nav__title { white-space: nowrap; font-size: .82rem; }
  .settings-nav__desc { display: none; }
  .settings-tabs__panel { gap: var(--s-3); }
  .settings-panel-head { display: none; }
  .settings-grid { grid-template-columns: 1fr; }
  .action-card__icon { width: 34px; height: 34px; margin-bottom: 0; }
  .action-card .btn,
  .settings-actions .btn { width: 100%; justify-content: center; }
  .connection-status {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "icon text"
      "badge badge";
    gap: var(--s-2) var(--s-3);
    padding: var(--s-3);
    align-items: start;
  }
  .connection-status__icon {
    grid-area: icon;
    width: 36px;
    height: 36px;
    align-self: start;
  }
  .connection-status__icon svg { width: 17px; height: 17px; }
  .connection-status__text { grid-area: text; }
  .connection-status__text code { font-size: .75rem; }
  .connection-status .badge {
    grid-area: badge;
    width: auto;
    justify-self: stretch;
    justify-content: center;
    padding-block: var(--s-1);
    margin-top: var(--s-1);
  }
  .settings-form { gap: var(--s-4); }
  .settings-actions { margin-top: 0; padding-top: var(--s-3); }
  .placeholder-chips { display: grid; grid-template-columns: 1fr 1fr; }
  .placeholder-chip { padding-block: var(--s-2); overflow: hidden; text-overflow: ellipsis; }
  #msg { left: var(--s-3); right: var(--s-3); bottom: var(--s-3); max-width: none; }
  .search-filter-group { flex-direction: column; align-items: stretch; gap: var(--s-2); padding: var(--s-3); }
  .search { min-width: 0; }
  .filter-separator { display: none; }
  .filter-control { gap: var(--s-1); }
  .filter-label { gap: 3px; }
  .bar-chart { column-gap: var(--s-2); }
  .bar-chart__yaxis { padding-right: var(--s-2); }
  .bar-chart__ytick { font-size: .62rem; }
  .bar-chart__value-tag { display: none; }
  .bar-chart__bars { gap: var(--s-1); padding: 0 var(--s-1); }
  .bar-chart__bar { max-width: 28px; }
  .bar-chart__axis { gap: var(--s-1); padding: var(--s-2) var(--s-1) 0; }
  .bar-chart__axis-label { font-size: .68rem; }
}

/* ---- htmx loading feedback ---------------------------------------------- */
@keyframes spin { to { transform: rotate(360deg); } }
.btn.htmx-request, .icon-btn.htmx-request { pointer-events: none; opacity: .7; }
.btn.htmx-request svg, .icon-btn.htmx-request svg { animation: spin .6s linear infinite; }
.btn__spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
.btn:not(.htmx-request) .btn__spinner { display: none; }
.btn.htmx-request .btn__label svg { display: none; }
form.htmx-request .btn--primary { pointer-events: none; opacity: .7; }
form.htmx-request .btn--primary svg { animation: spin .6s linear infinite; }
.sort-link.htmx-request { opacity: .5; }
.search:has(.input.htmx-request) > svg:first-child { animation: spin .6s linear infinite; color: var(--accent); }

/* ---- PDF preview (modal de contrato) ------------------------------------ */
.pdf-preview { width: 100%; height: 70vh; border: 0; border-radius: var(--r-lg); background: var(--surface-2); }

/* ---- Sortable column links (ponytail: inline, no icon deps) ---- */
.sort-link {
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.sort-link--active { color: var(--accent); font-weight: 700; }

/* ---- 19. Mídia (imagens/documentos de veículo) ---------------------------- */
.midia-grid { display: flex; flex-wrap: wrap; gap: var(--s-2); margin: var(--s-2) 0; }
.midia-item { position: relative; }
.midia-item img { width: 72px; height: 72px; border-radius: var(--r); object-fit: cover; border: 1px solid var(--border); }
.midia-item .btn { position: absolute; top: 2px; right: 2px; }
.midia-list { list-style: none; display: flex; flex-direction: column; gap: var(--s-1); margin: var(--s-2) 0; padding: 0; }
.midia-list__item { display: flex; align-items: center; gap: var(--s-2); font-size: .84rem; }
.midia-list__item svg { width: 16px; height: 16px; color: var(--text-tertiary); }
.midia-list__item a { color: var(--text); text-decoration: none; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.midia-list__item a:hover { color: var(--accent); }
.midia-thumb {
  border: 0;
  background: none;
  padding: 0;
  cursor: zoom-in;
}

.midia-grid--placeholder {
  margin-bottom: var(--s-2);
}

.midia-item--placeholder {
  width: 72px;
  height: 72px;
}

.midia-placeholder {
  width: 72px;
  height: 72px;
  border-radius: var(--r);
  border: 1px dashed var(--border);
  background: linear-gradient(135deg, var(--surface-muted), var(--surface));
  display: grid;
  place-items: center;
  color: var(--text-tertiary);
}

.midia-placeholder svg {
  width: 22px;
  height: 22px;
}

.midia-placeholder--pdf {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.midia-placeholder--pdf span {
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .03em;
}

.image-preview {
  max-width: min(96vw, 1200px);
  max-height: 96vh;
  border: 0;
  border-radius: 16px;
  padding: 12px;
  background: var(--surface);
}

.image-preview::backdrop {
  background: rgba(0, 0, 0, .78);
}

.image-preview img {
  display: block;
  max-width: 92vw;
  max-height: 88vh;
  object-fit: contain;
}

.image-preview__close {
  position: absolute;
  top: 16px;
  right: 16px;
}

/* ---- 20. Media manager (modais de imagens/documentos) -------------------- */
.mmgr__count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px; margin-left: var(--s-1);
  border-radius: var(--r-full); background: var(--accent-soft);
  color: var(--accent); font-size: .72rem; font-weight: 700; vertical-align: middle;
}

.mmgr__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(116px, 1fr));
  gap: var(--s-2);
}

.mmgr__card {
  position: relative; aspect-ratio: 1;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface-2); overflow: hidden;
  transition: border-color .12s, box-shadow .12s;
}
.mmgr__card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }

.mmgr__thumb {
  position: relative; display: block; width: 100%; height: 100%;
  padding: 0; border: 0; background: none; cursor: zoom-in;
}
.mmgr__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mmgr__thumb::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(10,11,13,.32), transparent 46%);
  opacity: 0; transition: opacity .12s;
}
.mmgr__card:hover .mmgr__thumb::after { opacity: 1; }

.mmgr__doc {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; width: 100%; height: 100%; padding: var(--s-2);
  text-align: center; text-decoration: none; color: var(--text-secondary);
  transition: background .12s, color .12s;
}
.mmgr__doc:hover { background: var(--surface-hover); color: var(--accent); }
.mmgr__doc-icon svg { width: 30px; height: 30px; }
.mmgr__doc-badge {
  font-size: .6rem; font-weight: 700; letter-spacing: .04em;
  padding: 1px 5px; border-radius: var(--r-sm);
  background: var(--surface-2); color: var(--text-tertiary);
}
.mmgr__doc-name {
  max-width: 100%; margin-top: 2px; font-size: .68rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.mmgr__del {
  position: absolute; top: var(--s-1); right: var(--s-1); z-index: 2;
  width: 26px; height: 26px; display: grid; place-items: center;
  border: 0; border-radius: var(--r); cursor: pointer;
  background: rgba(10,11,13,.62); color: #fff;
  backdrop-filter: blur(2px); transition: background .12s, opacity .12s;
}
.mmgr__del:hover { background: var(--danger); }
.mmgr__del svg { width: 15px; height: 15px; }
@media (hover: hover) {
  .mmgr__del { opacity: 0; }
  .mmgr__card:hover .mmgr__del, .mmgr__card:focus-within .mmgr__del { opacity: 1; }
}

.mmgr__upload {
  display: flex; flex-direction: column; gap: var(--s-3);
  padding: var(--s-4); border-top: 1px solid var(--border);
  background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.mmgr__drop {
  position: relative; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
  padding: var(--s-5) var(--s-4); text-align: center;
  border: 1.5px dashed var(--border-strong); border-radius: var(--r-md);
  background: var(--surface); color: var(--text-secondary); cursor: pointer;
  transition: border-color .12s, background .12s;
}
.mmgr__drop:hover { border-color: var(--accent); background: var(--accent-soft); }
.mmgr__drop input[type="file"] {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer;
}
.mmgr__drop-icon {
  width: 40px; height: 40px;
  margin-bottom: var(--s-1); border-radius: var(--r-full);
  background: var(--surface-2); color: var(--accent);
}
.mmgr__drop-icon svg { width: 20px; height: 20px; }
.mmgr__drop-text { font-size: .86rem; font-weight: 550; color: var(--text); }
.mmgr__drop-hint { font-size: .72rem; color: var(--text-tertiary); }
.mmgr__upload-actions { display: flex; justify-content: flex-end; }

/* ---- 21. Bar chart --------------------------------------------------------- */
.bar-chart {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: var(--s-3);
  min-width: 0;
}
.bar-chart__inner { display: contents; }
.bar-chart__yaxis {
  display: flex; flex-direction: column; justify-content: space-between;
  height: 240px; padding-right: var(--s-3); border-right: 1px dashed var(--border);
  text-align: right;
}
.bar-chart__ytick { font-size: .70rem; color: var(--text-tertiary); font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 500; }

.bar-chart__plot {
  position: relative; min-width: 0; height: 240px;
  background-image: linear-gradient(to top, var(--border) 1px, transparent 1px);
  background-size: 100% 20%;
  border-bottom: 1px solid var(--border);
}
.bar-chart__bars { position: absolute; inset: 0; display: flex; align-items: flex-end; gap: var(--s-3); padding: 0 var(--s-3); }
.bar-chart__col { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; align-items: center; position: relative; }

.bar-chart__value-tag {
  font-size: .68rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
  transition: opacity .2s, transform .2s;
  pointer-events: none;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-chart__bar {
  width: 100%; max-width: 44px; min-height: 4px;
  background: linear-gradient(180deg, var(--accent) 0%, rgba(var(--accent-rgb, 99, 102, 241), 0.65) 100%);
  border-radius: 6px 6px 2px 2px;
  cursor: pointer;
  position: relative;
  transition: transform .2s cubic-bezier(0.34, 1.56, 0.64, 1), filter .2s, box-shadow .2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  animation: barGrow 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transform-origin: bottom;
}

@keyframes barGrow {
  from { transform: scaleY(0); }
  to { transform: scaleY(1); }
}

.bar-chart__bar::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 6px 6px 0 0;
}

.bar-chart__col:hover .bar-chart__bar,
.bar-chart__bar:hover,
.bar-chart__bar:focus-visible {
  filter: brightness(1.15);
  transform: translateY(-4px) scaleX(1.03);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
  outline: none;
}

.bar-chart__col:hover .bar-chart__value-tag {
  opacity: 1;
  transform: translateY(-2px);
  color: var(--accent);
}

.bar-chart__axis {
  grid-column: 2;
  display: flex; gap: var(--s-3);
  padding: var(--s-2) var(--s-3) 0;
  margin-top: var(--s-2);
}
.bar-chart__axis-label {
  flex: 1; min-width: 0; text-align: center;
  font-size: .76rem; font-weight: 500; color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.bar-chart__tooltip {
  grid-column: 1 / -1;
  position: fixed; z-index: 50; pointer-events: none; opacity: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  padding: var(--s-2) var(--s-3); font-size: .78rem;
  transition: opacity .15s ease, transform .15s ease;
  transform: translate(-50%, -100%) translateY(-6px);
  backdrop-filter: blur(8px);
  max-width: min(90vw, 240px);
}
.bar-chart__tooltip[data-visible="true"] { opacity: 1; transform: translate(-50%, -100%) translateY(-10px); }
.bar-chart__tooltip strong { display: block; font-size: .95rem; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.bar-chart__tooltip span { color: var(--text-secondary); }

.chart-table-details summary { cursor: pointer; font-size: .78rem; font-weight: 500; color: var(--text-secondary); margin-top: var(--s-4); transition: color .15s; }
.chart-table-details summary:hover { color: var(--accent); }
.chart-table-details .table-wrap { margin-top: var(--s-3); }
