/* FACILE CAR: plain CSS, no build step. Colors are variables so the theme can change in one place. */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dde1e7;
  --text: #1d2330;
  --text-muted: #5d6675;
  --primary: #1f5fbf;
  --primary-text: #ffffff;
  --primary-soft: #e6eefa;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --success: #1e7a46;
  --success-soft: #e5f4ec;
  --warning: #8a5a00;
  --warning-soft: #fdf3dc;
  --radius: 8px;
  --sidebar-width: 260px;
  --topbar-height: 56px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --surface: #1c2027;
    --surface-2: #242932;
    --border: #333a45;
    --text: #e6e9ee;
    --text-muted: #9aa3b0;
    --primary: #6aa1ff;
    --primary-text: #0d1420;
    --primary-soft: #1d2b44;
    --danger: #ff8a80;
    --danger-soft: #3a1f1f;
    --success: #6fd39b;
    --success-soft: #16301f;
    --warning: #f2c46b;
    --warning-soft: #352a12;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--primary); }
h1, h2, h3 { line-height: 1.2; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.icon { width: 20px; height: 20px; flex: none; }

/* ---------- Buttons and forms */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 14px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: inherit; cursor: pointer; text-decoration: none;
}
.button:hover { background: var(--surface-2); }
.button--primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.button--primary:hover { filter: brightness(1.08); background: var(--primary); }
.button--ghost { border-color: transparent; background: transparent; }
.button--block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 0.87rem; color: var(--text-muted); }
input[type="text"], input[type="email"], input[type="password"], input[type="search"],
input[type="number"], input[type="date"], select, textarea {
  min-height: 38px; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: inherit;
}
.form { display: flex; flex-direction: column; gap: 14px; }

.flash { padding: 10px 14px; border-radius: var(--radius); margin: 0 0 16px; }
.flash--notice { background: var(--success-soft); color: var(--success); }
.flash--alert { background: var(--danger-soft); color: var(--danger); }

/* ---------- Sign-in page */
.sign-in-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.sign-in__card {
  width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 32px 28px;
}
.sign-in__brand { margin: 0; font-size: 1.6rem; letter-spacing: 0.02em; }
.sign-in__subtitle { margin: 4px 0 24px; color: var(--text-muted); }
.sign-in__help { margin: 18px 0 0; font-size: 0.87rem; color: var(--text-muted); }

/* ---------- App shell: top bar, sidebar, content */
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar-height);
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar__brand { font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; letter-spacing: 0.02em; }
.topbar__menu-button { display: none; background: none; border: 0; color: var(--text); padding: 6px; cursor: pointer; }
.topbar__user { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.topbar__name { color: var(--text-muted); }

.shell { display: flex; min-height: calc(100vh - var(--topbar-height)); }

.sidebar {
  width: var(--sidebar-width); flex: none; padding: 12px 10px 24px;
  background: var(--surface); border-right: 1px solid var(--border);
  position: sticky; top: var(--topbar-height); height: calc(100vh - var(--topbar-height)); overflow-y: auto;
}
.sidebar a, .sidebar summary, .sidebar .is-soon {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px;
  color: var(--text); text-decoration: none;
}
.sidebar__home { font-weight: 600; margin-bottom: 6px; }
.sidebar summary { font-weight: 600; cursor: pointer; list-style: none; }
.sidebar summary::-webkit-details-marker { display: none; }
.sidebar summary::after { content: "▸"; margin-left: auto; color: var(--text-muted); transition: transform 0.15s; }
.sidebar details[open] > summary::after { transform: rotate(90deg); }
.sidebar ul { list-style: none; margin: 0 0 6px; padding: 0 0 0 30px; }
.sidebar a:hover, .sidebar summary:hover { background: var(--surface-2); }
.sidebar a.is-current { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.sidebar .is-soon { color: var(--text-muted); cursor: default; }

.content { flex: 1; min-width: 0; padding: 24px 28px 48px; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-title { margin: 0 0 20px; font-size: 1.5rem; }

@media (max-width: 860px) {
  .topbar__menu-button { display: inline-flex; }
  .topbar__name { display: none; }
  .sidebar {
    position: fixed; left: 0; top: var(--topbar-height); z-index: 15;
    transform: translateX(-100%); transition: transform 0.2s; box-shadow: 0 8px 24px rgb(0 0 0 / 0.15);
  }
  .sidebar.is-open { transform: none; }
  .content { padding: 18px 16px 40px; }
}

/* ---------- Dashboard */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 28px; }
.tile {
  display: flex; flex-direction: column; gap: 4px; padding: 16px 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.tile__label { color: var(--text-muted); font-size: 0.9rem; }
.tile__value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile__note { color: var(--text-muted); font-size: 0.85rem; }

.categories { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.category-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.category-card__title { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; padding: 0 6px; font-size: 1.05rem; }
.category-card__items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.menu-item {
  display: flex; flex-direction: column; gap: 2px; padding: 10px 10px; border-radius: 6px;
  color: var(--text); text-decoration: none;
}
a.menu-item:hover { background: var(--primary-soft); }
a.menu-item .menu-item__title { color: var(--primary); font-weight: 600; }
.menu-item.is-soon .menu-item__title { color: var(--text-muted); font-weight: 600; }
.menu-item__description { color: var(--text-muted); font-size: 0.87rem; }
.badge {
  display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-muted); font-size: 0.75rem; font-weight: 500; vertical-align: middle;
}

/* ---------- Lists and tables */
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 12px; }
.filters .field { min-width: 200px; }
.result-count { color: var(--text-muted); margin: 0 0 8px; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th { background: var(--surface-2); font-size: 0.85rem; color: var(--text-muted); font-weight: 600; position: sticky; top: 0; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 0.88rem; }
.is-negative { color: var(--danger); }

.status { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.82rem; font-weight: 600; }
.status--em-estoque { background: var(--primary-soft); color: var(--primary); }
.status--floorplan { background: var(--warning-soft); color: var(--warning); }
.status--vendido { background: var(--success-soft); color: var(--success); }
.status--desmanchado { background: var(--surface-2); color: var(--text-muted); }

/* ---------- Detail pages, sections and forms */
.breadcrumb { margin-bottom: 8px; color: var(--text-muted); font-size: 0.9rem; }
.breadcrumb a { color: var(--text-muted); }
.page-title--tight { margin-bottom: 4px; }
.subtitle { margin: 0 0 20px; color: var(--text-muted); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.tiles--compact .tile__value { font-size: 1.3rem; }
.two-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-bottom: 8px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.card__title { margin: 0 0 12px; font-size: 1.05rem; }
.details { display: grid; grid-template-columns: minmax(130px, auto) 1fr; gap: 6px 16px; margin: 0; }
.details dt { color: var(--text-muted); }
.details dd { margin: 0; }
.details--money dd { text-align: right; font-variant-numeric: tabular-nums; }
.details .total { font-weight: 700; border-top: 1px solid var(--border); padding-top: 6px; }

.section { margin-top: 28px; scroll-margin-top: calc(var(--topbar-height) + 12px); }
.section__header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.section__header h2 { margin: 0; font-size: 1.15rem; display: flex; align-items: baseline; gap: 10px; }
.section__total { color: var(--text-muted); font-weight: 500; font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.hint { color: var(--text-muted); margin: 0 0 10px; font-size: 0.92rem; }
.empty { color: var(--text-muted); margin: 0; padding: 14px 16px; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.page-footer-hint { margin-top: 32px; color: var(--text-muted); font-size: 0.87rem; }
.row-actions { text-align: right; }
.strong { font-weight: 700; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.button--small { min-height: 32px; padding: 0 12px; font-size: 0.9rem; }
.button--danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.button--danger:hover { background: var(--danger-soft); }
form.button_to { display: inline; }

.record-form { max-width: 960px; display: flex; flex-direction: column; gap: 18px; }
.field-group { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 14px 18px 18px; margin: 0; }
.field-group legend { padding: 0 6px; font-weight: 600; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px 18px; }
.field--wide { grid-column: 1 / -1; }
.field--checkbox { flex-direction: row-reverse; justify-content: flex-end; align-items: center; gap: 8px; }
.field--checkbox label { font-size: 1rem; color: var(--text); }
.field--checkbox input { width: 18px; height: 18px; }
.form-actions { display: flex; gap: 10px; }
.flash ul { margin: 6px 0 0; padding-left: 20px; }
.flash p { margin: 0; }
.flash--warning { background: var(--warning-soft); color: var(--warning); padding: 10px 14px; border-radius: var(--radius); margin: 0 0 12px; }
.flash__action { margin-left: 10px; font-weight: 600; color: inherit; }

.status--paid { background: var(--success-soft); color: var(--success); }
.status--overdue { background: var(--danger-soft); color: var(--danger); }
.status--partial { background: var(--warning-soft); color: var(--warning); }
.status--due { background: var(--surface-2); color: var(--text-muted); }

/* ---------- Printable receipt (always black on white) */
.print-page { background: #fff; color: #000; padding: 24px; color-scheme: light; }
.print-toolbar { display: flex; gap: 8px; max-width: 720px; margin: 0 auto 20px; }
.receipt { max-width: 720px; margin: 0 auto; font-family: Georgia, "Times New Roman", serif; color: #000; }
.receipt__copy-label { text-align: center; font-weight: 700; letter-spacing: 0.08em; margin: 0 0 8px; font-family: system-ui, sans-serif; font-size: 0.8rem; }
.receipt__header { text-align: center; border-bottom: 2px solid #000; padding-bottom: 6px; margin-bottom: 12px; }
.receipt__header h1 { margin: 0; font-size: 1.6rem; letter-spacing: 0.06em; }
.receipt__header p { margin: 2px 0 0; font-size: 1.1rem; }
.receipt__fields { display: grid; grid-template-columns: 200px 1fr; gap: 5px 12px; margin: 0; }
.receipt__fields dt { font-weight: 700; font-family: system-ui, sans-serif; font-size: 0.82rem; padding-top: 2px; }
.receipt__fields dd { margin: 0; }
.receipt__signature { display: flex; gap: 24px; margin-top: 26px; }
.receipt__signature .line { display: inline-block; width: 260px; border-bottom: 1px solid #000; }
.receipt__signature .line--short { width: 120px; }
.receipt__footer { margin-top: 14px; font-size: 0.78rem; text-align: center; color: #333; }
.receipt__cut { max-width: 720px; margin: 28px auto; border: 0; border-top: 1px dashed #000; }

@media print {
  .print-toolbar { display: none; }
  .print-page { padding: 0; }
  .receipt__cut { margin: 18px auto; }
}

/* ---------- Reports */
.table tfoot th { background: var(--surface-2); color: var(--text); font-weight: 700; border-top: 2px solid var(--border); }
.row--late td { background: var(--danger-soft); }
.row--soon td { background: var(--warning-soft); }
.report-grand-total { margin-top: 20px; font-weight: 700; text-align: right; }
.print-only { display: none; }

.overdue-list { display: flex; flex-direction: column; gap: 8px; }
.overdue-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.overdue-item summary {
  display: grid; grid-template-columns: minmax(160px, 1.2fr) minmax(140px, 1fr) minmax(180px, 1fr) auto;
  gap: 12px; align-items: center; padding: 12px 16px; cursor: pointer; list-style: none;
}
.overdue-item summary::-webkit-details-marker { display: none; }
.overdue-item[open] summary { border-bottom: 1px solid var(--border); }
.overdue-item__buyer { font-weight: 600; }
.overdue-item__vehicle, .overdue-item__meta { color: var(--text-muted); font-size: 0.9rem; }
.overdue-item__amount { font-weight: 700; color: var(--danger); font-variant-numeric: tabular-nums; text-align: right; }
.overdue-item__body { padding: 12px 16px 14px; }
.overdue-item__links { display: flex; gap: 8px; margin: 12px 0 0; }
@media (max-width: 700px) {
  .overdue-item summary { grid-template-columns: 1fr auto; }
  .overdue-item__vehicle, .overdue-item__meta { grid-column: 1; }
}

/* Printing any app page: just the content, no menus or buttons */
@media print {
  body:not(.print-page) { background: #fff; color: #000; }
  .topbar, .sidebar, .no-print, .filters, .flash, .breadcrumb, .row-actions, .overdue-item__links { display: none !important; }
  .shell { display: block; }
  .content { padding: 0; }
  .print-only { display: inline; }
  .tile, .card, .table-wrap, .overdue-item { border-color: #999; break-inside: avoid; }
  .table th, .table td { padding: 4px 6px; }
  .overdue-item summary { border-bottom: 0; }
  a { color: inherit; text-decoration: none; }
}

/* ---------- Users and account */
.card--narrow, .record-form--narrow { max-width: 560px; }
.card--narrow { margin-bottom: 18px; }
.field-stack { display: flex; flex-direction: column; gap: 14px; }
.temp-password { font-size: 1.3rem; letter-spacing: 0.06em; padding: 4px 10px; background: var(--surface-2); border-radius: 6px; user-select: all; }
.row--muted td { color: var(--text-muted); }
.muted { color: var(--text-muted); font-size: 0.88rem; }

/* ---------- Resolve missing payments */
.steps { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0 0 18px; }
.steps li { padding: 4px 12px; border-radius: 999px; background: var(--surface-2); color: var(--text-muted); font-size: 0.88rem; }
.steps li.is-current { background: var(--primary); color: var(--primary-text); font-weight: 600; }
.steps li.is-done { background: var(--success-soft); color: var(--success); }
.bulk-bar {
  position: sticky; top: var(--topbar-height); z-index: 5; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 14px; margin-bottom: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.bulk-bar__all { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.bulk-bar__count { color: var(--text-muted); margin-right: auto; }
.resolve-group { margin-bottom: 14px; }
.resolve-group__header { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 6px 4px; }
.resolve-group__header label { display: flex; align-items: center; gap: 8px; }
.resolve-group__meta { color: var(--text-muted); font-size: 0.9rem; }
.table--form td { vertical-align: middle; }
.table--form input[type="number"], .table--form input[type="date"] { min-height: 34px; padding: 4px 8px; }
.input--money { width: 120px; text-align: right; }
.row--error td { background: var(--danger-soft); }
.field-error { display: block; color: var(--danger); font-size: 0.82rem; margin-top: 2px; white-space: normal; }
.form-actions--spaced { margin-top: 18px; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); }
