/* ==========================================================================
   CRM Automotivo — base
   ========================================================================== */
:root {
  --ink: #101828;
  --ink-2: #344054;
  --muted: #667085;
  --faint: #667085;
  --line: #e4e7ec;
  --line-2: #eaecf0;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --sidebar: #111b2e;
  --sidebar-2: #1b2942;
  --sidebar-text: #c7d2e3;
  --accent: #2457d6;
  --accent-strong: #1a43ad;
  --accent-soft: #eef3ff;
  --success: #087a55;
  --success-soft: #e8f7f1;
  --warning: #a15c0a;
  --warning-soft: #fff6e6;
  --danger: #c9342a;
  --danger-soft: #fdf0ef;
  --info-soft: #eff6ff;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .045);
  --shadow-lg: 0 16px 48px rgba(16, 24, 40, .18), 0 2px 8px rgba(16, 24, 40, .08);
  --font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

::selection { background: #d9e5ff; color: #142c63; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

svg.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cfd6e0; border: 3px solid transparent; background-clip: content-box; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background-color: #aeb8c6; }

[hidden] { display: none !important; }

/* ==========================================================================
   Login
   ========================================================================== */
.login-view { display: grid; grid-template-columns: minmax(360px, 44%) 1fr; min-height: 100vh; }

.login-art {
  position: relative;
  overflow: hidden;
  background: linear-gradient(155deg, #14233d 0%, #0d1729 60%, #0a1220 100%);
  color: #fff;
  display: flex;
  align-items: center;
}
.login-art__inner { position: relative; z-index: 1; padding: 56px clamp(36px, 6vw, 92px); max-width: 620px; }
.login-art h1 {
  margin: 92px 0 18px;
  font-size: clamp(34px, 3.6vw, 50px);
  line-height: 1.1;
  letter-spacing: -.035em;
  font-weight: 700;
}
.login-art p { margin: 0; max-width: 42ch; color: #b8c5da; font-size: 16px; line-height: 1.65; }
.login-art__lines { display: flex; gap: 8px; margin-top: 52px; }
.login-art__lines span { height: 3px; width: 38px; border-radius: 4px; background: rgba(255,255,255,.16); }
.login-art__lines span:first-child { width: 76px; background: #4f8cff; }

.brand { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 500; letter-spacing: -.02em; }
.brand b { font-weight: 750; }
.brand__mark {
  width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--accent); color: #fff;
}
.brand__mark .icon { width: 20px; height: 20px; }
.brand--light { color: #fff; }
.brand--light .brand__mark { background: #3b74f0; }

.login-panel { display: grid; place-items: center; padding: 40px 24px; }
.login-card { width: min(100%, 400px); }
.login-card__head { display: flex; align-items: center; gap: 14px; margin-bottom: 32px; }
.login-card__badge {
  width: 42px; height: 42px; border-radius: 11px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.login-card h2 { margin: 0; font-size: 22px; letter-spacing: -.03em; }
.login-card p { margin: 4px 0 0; color: var(--muted); }
.login-hint { margin-top: 20px !important; font-size: 12px; color: var(--faint) !important; text-align: center; }

/* ==========================================================================
   Campos e botoes
   ========================================================================== */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 18px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field input, .field select, .field textarea,
.input, .select, .textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 11px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid #d0d5dd;
  border-radius: var(--radius-sm);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field textarea, .textarea { min-height: 90px; resize: vertical; }
.field input::placeholder, .textarea::placeholder { color: #667085; }
.field input:hover, .field select:hover, .field textarea:hover,
.input:hover, .select:hover { border-color: #98a2b3; }
.field input:focus, .field select:focus, .field textarea:focus,
.input:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(36, 87, 214, .14);
}
.field input:disabled, .field select:disabled { background: #f9fafb; color: var(--faint); cursor: not-allowed; }
.field__hint { font-size: 12px; color: var(--muted); }
.form-error {
  margin: -6px 0 16px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px;
  padding: 8px 15px;
  font: inherit; font-size: 13.5px; font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn .icon { width: 16px; height: 16px; }
.btn--primary { background: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(16,24,40,.12); }
.btn--primary:hover { background: var(--accent-strong); }
.btn--secondary { background: var(--surface); color: var(--ink-2); border-color: #d0d5dd; }
.btn--secondary:hover { background: #f9fafb; border-color: #98a2b3; }
.btn--ghost { background: transparent; color: var(--ink-2); }
.btn--ghost:hover { background: #f2f4f7; }
.btn--danger { background: var(--surface); color: var(--danger); border-color: #f3c9c5; }
.btn--danger:hover { background: var(--danger-soft); }
.btn--danger-solid { background: var(--danger); color: #fff; }
.btn--danger-solid:hover { background: #a92a22; }
.btn--block { width: 100%; }
.btn[disabled], .btn.is-loading { opacity: .6; cursor: not-allowed; pointer-events: none; }

.icon-btn {
  width: 34px; height: 34px;
  display: inline-grid; place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { background: #f2f4f7; color: var(--ink); }
.icon-btn--danger:hover { background: var(--danger-soft); color: var(--danger); }

/* ==========================================================================
   Layout do app
   ========================================================================== */
.app-view { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 246px;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  color: var(--sidebar-text);
  z-index: 40;
}
.sidebar__brand {
  min-height: 68px;
  padding: 20px;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.nav { padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar__foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.07); }
.nav__item {
  width: 100%;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  font: inherit; font-size: 13.5px; font-weight: 500;
  color: var(--sidebar-text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.nav__item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav__item.is-active { background: var(--sidebar-2); color: #fff; box-shadow: inset 2px 0 0 #5b8def; }
.nav__item--logout:hover { background: rgba(217,45,32,.18); color: #ffb4ae; }
.nav__item .icon { width: 18px; height: 18px; opacity: .9; }

.app-main { margin-left: 246px; width: calc(100% - 246px); min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: 68px;
  display: flex; align-items: center; gap: 14px;
  padding: 0 28px;
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar__menu { display: none; }
.topbar__title { margin: 0; font-size: 19px; line-height: 1.2; letter-spacing: -.025em; font-weight: 680; }
.topbar__subtitle { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.topbar__right { margin-left: auto; }
.user-badge {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 5px 11px 5px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 13px; font-weight: 600;
  cursor: default;
}
.user-badge__avatar {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  font-size: 11px; font-weight: 750;
}
.user-badge__role { color: var(--muted); font-weight: 500; font-size: 11px; }

.content { padding: 26px 28px 56px; max-width: 1560px; margin: 0 auto; outline: none; }
.sidebar-overlay { position: fixed; inset: 0; background: rgba(9,16,29,.55); z-index: 35; }

/* ==========================================================================
   Blocos de conteudo
   ========================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card__head {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line-2);
}
.card__head h2 { margin: 0; font-size: 15px; letter-spacing: -.015em; font-weight: 680; }
.card__head p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.card__head .spacer { margin-left: auto; }
.card__body { padding: 18px; }

.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.toolbar__search { position: relative; flex: 1 1 260px; max-width: 380px; }
.toolbar__search .icon {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--faint); pointer-events: none;
}
.toolbar__search input { padding-left: 35px; }
.toolbar select { width: auto; min-width: 150px; background-color: #fff; }
.toolbar .spacer { flex: 1; }
.toolbar__count { font-size: 12px; color: var(--muted); white-space: nowrap; }

.grid { display: grid; gap: 16px; }
.grid--stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--two { grid-template-columns: minmax(0, 1.45fr) minmax(300px, 1fr); }

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stat__label { font-size: 12px; font-weight: 600; color: var(--muted); }
.stat__icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.stat__icon--green { background: var(--success-soft); color: var(--success); }
.stat__icon--amber { background: var(--warning-soft); color: var(--warning); }
.stat__icon--slate { background: #f2f4f7; color: var(--ink-2); }
.stat__value { margin-top: 12px; font-size: 23px; font-weight: 720; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.stat__foot { margin-top: 5px; font-size: 11.5px; color: var(--muted); }

.balance {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 20px;
  padding: 22px 24px;
  background: linear-gradient(120deg, #152542, #1d3562);
  color: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.balance__label { font-size: 12px; color: #b9c8e0; font-weight: 600; }
.balance__value { margin-top: 6px; font-size: 32px; font-weight: 730; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.balance__meta { margin-top: 6px; font-size: 12px; color: #b9c8e0; }
.balance__aside { text-align: right; font-size: 12px; color: #b9c8e0; }
.balance__aside b { display: block; margin-top: 4px; color: #fff; font-size: 17px; font-variant-numeric: tabular-nums; }

.chart { display: flex; align-items: flex-end; gap: 14px; height: 168px; padding-top: 12px; }
.chart__col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.chart__bars { width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 3px; height: 100%; }
.chart__bar { width: min(18px, 40%); border-radius: 4px 4px 0 0; min-height: 2px; transition: height .3s ease; }
.chart__bar--aluguel { background: #4d81f5; }
.chart__bar--venda { background: #8fb6ff; }
.chart__label { font-size: 11px; color: var(--muted); text-transform: capitalize; }
.chart-legend { display: flex; gap: 16px; margin-top: 14px; font-size: 11.5px; color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }

/* ==========================================================================
   Tabelas
   ========================================================================== */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  position: sticky; top: 0;
  text-align: left;
  padding: 11px 14px;
  background: #fafbfc;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase;
  white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color .12s ease; }
.table tbody tr:hover { background: #fafbfe; }
.table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table td.actions { text-align: right; white-space: nowrap; }
.table .cell-main { font-weight: 600; color: var(--ink); }
.table .cell-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.table .cell-clip { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table .row-click { cursor: pointer; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 650;
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--neutral { background: #f2f4f7; color: #475467; }
.badge--blue { background: var(--info-soft); color: #175cd3; }
.badge--green { background: var(--success-soft); color: var(--success); }
.badge--amber { background: var(--warning-soft); color: var(--warning); }
.badge--red { background: var(--danger-soft); color: var(--danger); }

.row-actions { display: inline-flex; align-items: center; gap: 2px; }

.empty { padding: 56px 20px; text-align: center; }
.empty__icon {
  width: 46px; height: 46px; margin: 0 auto 14px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: #f2f4f7; color: var(--muted);
}
.empty__icon .icon { width: 22px; height: 22px; }
.empty h3 { margin: 0 0 6px; font-size: 15px; }
.empty p { margin: 0 auto 18px; max-width: 40ch; color: var(--muted); font-size: 13px; }

.loading { padding: 54px 20px; text-align: center; color: var(--muted); font-size: 13px; }
.spinner {
  width: 22px; height: 22px; margin: 0 auto 12px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   Modal
   ========================================================================== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 5vh 16px;
  background: rgba(12, 20, 34, .5);
  overflow-y: auto;
  animation: fade-in .15s ease-out;
}
.modal {
  width: min(100%, 620px);
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  animation: modal-in .18s cubic-bezier(.2, .9, .3, 1);
  margin: auto 0;
}
.modal--wide { width: min(100%, 860px); }
.modal__head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}
.modal__head h2 { margin: 0; font-size: 17px; letter-spacing: -.02em; }
.modal__head p { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); }
.modal__head .icon-btn { margin-left: auto; }
.modal__body { padding: 22px; }
.modal__foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: #fcfcfd;
  border-radius: 0 0 12px 12px;
}
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-grid .field--full { grid-column: 1 / -1; }
.form-section {
  grid-column: 1 / -1;
  margin: 6px 0 2px;
  font-size: 11px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--faint);
  padding-top: 12px; border-top: 1px solid var(--line-2);
}
.calc-box {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 14px 16px;
  background: var(--accent-soft);
  border: 1px solid #dbe6ff;
  border-radius: var(--radius-sm);
}
.calc-box__item { font-size: 12px; color: #425a8f; }
.calc-box__item b { display: block; margin-top: 2px; font-size: 17px; color: #173b86; font-variant-numeric: tabular-nums; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 20px; }
.detail-item span { display: block; font-size: 11px; color: var(--muted); font-weight: 600; }
.detail-item b { display: block; margin-top: 2px; font-size: 14px; font-weight: 600; }
.note-box {
  white-space: pre-wrap;
  min-height: 72px;
  padding: 12px 14px;
  background: #fafbfc;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--ink-2);
}
.section-title { margin: 24px 0 12px; font-size: 13px; font-weight: 700; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.985); } to { opacity: 1; transform: none; } }

/* ==========================================================================
   Toasts
   ========================================================================== */
.toast-root {
  position: fixed; right: 20px; bottom: 20px; z-index: 80;
  display: flex; flex-direction: column; gap: 10px;
  max-width: min(360px, calc(100vw - 40px));
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px;
  background: var(--ink);
  color: #fff;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  animation: modal-in .18s ease-out;
}
.toast .icon { width: 17px; height: 17px; }
.toast--success .icon { color: #6ee7b7; }
.toast--error .icon { color: #fda29b; }
.toast--info .icon { color: #a7c7ff; }

/* ==========================================================================
   Responsivo
   ========================================================================== */
@media (max-width: 1180px) {
  .grid--stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--two { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.is-open { transform: none; }
  .app-main { margin-left: 0; width: 100%; }
  .topbar__menu { display: inline-grid; }
  .content { padding: 20px 16px 48px; }
  .topbar { padding: 0 16px; }
  .login-view { grid-template-columns: 1fr; }
  .login-art { display: none; }
}
@media (max-width: 620px) {
  .grid--stats { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .balance { flex-direction: column; align-items: flex-start; }
  .balance__aside { text-align: left; }
  .toolbar__search { max-width: none; }
  .modal__foot { flex-direction: column-reverse; }
  .modal__foot .btn { width: 100%; }
  .user-badge__role { display: none; }
}
