:root {
  --navy: #172b62;
  --navy2: #0f1e45;
  --blue: #0d5b9b;
  --cyan: #2e83c7;
  --green: #12b76a;
  --red: #d92d20;
  --amber: #b7791f;
  --white: #fff;
  --bg: #f4f7fb;
  --muted: #647086;
  --line: #dbe4f0;
  --shadow: 0 18px 46px rgba(15, 30, 69, .14);
  --radius: 20px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, Segoe UI, Arial, sans-serif;
  background: var(--bg);
  color: #111b33;
}
a { color: inherit; text-decoration: none; }
button,
input,
select,
textarea {
  font: inherit;
}

:focus-visible {
  outline: 3px solid #f2b84b;
  outline-offset: 3px;
}

.eyebrow {
  margin: 0 0 8px;
  color: #58a6e2;
  font-size: .76rem;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border: 0;
  border-radius: 999px;
  padding: 12px 20px;
  font-weight: 900;
  cursor: pointer;
}
.btn:disabled,
button:disabled {
  cursor: wait;
  opacity: .72;
}
.primary {
  color: #fff;
  background: linear-gradient(135deg, #1f80d0, #0d5b9b);
  box-shadow: 0 12px 26px rgba(13, 91, 155, .24);
}
.secondary {
  color: var(--navy);
  background: #fff;
  border: 1px solid var(--line);
}
.danger {
  color: #fff;
  background: var(--red);
}
.full { width: 100%; }

.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--navy2), var(--navy) 58%, var(--blue));
}
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 18px;
}
.auth-pending .login-card,
.auth-pending .sidebar,
.auth-pending .panel-main,
.auth-pending .pwa-install-button,
.auth-pending .pwa-install-help {
  visibility: hidden;
}
.auth-pending::before {
  content: "Validando acesso...";
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  color: #fff;
  background: linear-gradient(135deg, var(--navy2), var(--navy) 58%, var(--blue));
  font-weight: 900;
  z-index: 20;
}
.login-card {
  width: min(100%, 440px);
  padding: 30px;
  border: 1px solid rgba(255, 255, 255, .5);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}
.login-logo img {
  width: 100%;
  height: 145px;
  object-fit: cover;
  border-radius: 16px;
  margin-bottom: 22px;
}
.login-card h1 {
  margin: 0;
  color: var(--navy2);
  font-size: 2.25rem;
  line-height: 1.05;
}
.login-copy {
  margin: 12px 0 22px;
  color: var(--muted);
}
.login-form label,
.panel-form label {
  display: block;
  color: #26314d;
  font-weight: 900;
}
.login-form label { margin-bottom: 14px; }
input,
select,
textarea {
  width: 100%;
  margin-top: 7px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: #111b33;
}
textarea { resize: vertical; }
.form-error {
  min-height: 22px;
  margin: 0 0 12px;
  color: var(--red);
  font-weight: 800;
}
.back-link {
  display: inline-block;
  margin-top: 18px;
  color: var(--blue);
  font-weight: 900;
}

.panel-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow: hidden;
  padding: 24px;
  color: #fff;
  background: linear-gradient(180deg, var(--navy2), var(--navy));
}
.panel-brand {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 12px;
  font-weight: 900;
  letter-spacing: .03em;
}
.panel-brand img {
  width: 82px;
  height: 42px;
  object-fit: cover;
  border-radius: 8px;
}
.panel-nav {
  display: grid;
  min-height: 0;
  gap: 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
  scrollbar-gutter: stable;
}
.nav-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; margin-left: 6px; padding: 0 5px; border-radius: 999px; background: #d92d20; color: #fff; font-size: .72rem; }
.request-filters { display: grid; grid-template-columns: 2fr repeat(3, 1fr) auto; gap: 12px; align-items: end; margin-bottom: 16px; }
.request-filters label, .status-update-form label { display: grid; gap: 6px; font-weight: 700; color: var(--navy); }
.request-details { margin-top: 18px; }
.details-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.details-grid article { padding: 14px; border-radius: 12px; background: #f5f7fb; overflow-wrap: anywhere; }
.details-grid h3 { margin: 0 0 8px; color: var(--navy); font-size: .85rem; text-transform: uppercase; }
.details-grid p { margin: 4px 0; white-space: pre-wrap; }
.status-update-form { display: grid; grid-template-columns: 1fr 2fr auto; gap: 12px; align-items: end; margin-top: 18px; }
.nav-tab,
.logout-btn {
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 13px 14px;
  text-align: left;
  color: #fff;
  background: rgba(255, 255, 255, .08);
  font-weight: 900;
  cursor: pointer;
}
.nav-tab.active,
.nav-tab:hover {
  background: #fff;
  color: var(--navy);
}
.logout-btn {
  flex: 0 0 auto;
  margin-top: auto;
  background: rgba(217, 45, 32, .9);
}

.panel-main {
  min-width: 0;
  padding: 32px;
}
.panel-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 28px;
}
.panel-top h1 {
  margin: 0;
  color: var(--navy2);
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1;
}
.site-link {
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--navy);
  font-weight: 900;
}
.panel-view { display: none; }
.panel-view.active { display: block; }

.metric-grid,
.report-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.metric-card,
.report-card,
.panel-card,
.client-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 12px 34px rgba(15, 30, 69, .08);
}
.metric-card,
.report-card {
  padding: 20px;
}
.metric-card strong {
  display: block;
  margin-top: 8px;
  color: var(--navy);
  font-size: 2rem;
}
.metric-card span,
.report-card span,
.client-card span {
  color: var(--muted);
  font-weight: 800;
}
.panel-card { padding: 18px; }
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}
.section-title h2 {
  margin: 0;
  color: var(--navy2);
  font-size: clamp(1.55rem, 3vw, 2.35rem);
}

.panel-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 12px 34px rgba(15, 30, 69, .08);
}
.span-2 { grid-column: span 2; }
.form-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}
th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
th {
  color: var(--navy);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .08em;
}
td { color: #26314d; }
.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.small-btn {
  border: 0;
  border-radius: 999px;
  padding: 8px 11px;
  color: var(--navy);
  background: #edf4fb;
  font-size: .86rem;
  font-weight: 900;
  cursor: pointer;
}
.small-btn.danger {
  color: #fff;
  background: var(--red);
}
.status-pill {
  display: inline-flex;
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--navy);
  background: #edf4fb;
  font-size: .82rem;
  font-weight: 900;
}
.status-pendente { color: var(--amber); background: #fff7e6; }
.status-confirmada,
.status-disponivel { color: var(--green); background: #e9fbf2; }
.status-reservado,
.status-em-limpeza { color: var(--amber); background: #fff7e6; }
.status-cancelada,
.status-bloqueado,
.status-inativo,
.status-em-manutencao { color: var(--red); background: #fff1f0; }
.status-em-andamento,
.status-alugado,
.status-locado { color: var(--blue); background: #edf4fb; }
.status-concluida,
.status-resolvido,
.status-valido { color: var(--green); background: #e9fbf2; }
.status-agendada,
.status-a-vencer,
.status-atencao,
.status-aberto { color: var(--amber); background: #fff7e6; }
.status-vencido,
.status-critico { color: var(--red); background: #fff1f0; }
.status-informativo { color: var(--blue); background: #edf4fb; }
.small-btn.release { color: #fff; background: var(--green); }
.release-pending { color: var(--red); font-size: .78rem; font-weight: 900; }
.dashboard-pendencies { margin-top: 20px; }
.fleet-operation-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.fleet-operation-grid > section { min-width: 0; }
.fleet-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fleet-form h3 { margin: 0; color: var(--navy); }
.fleet-alerts-card { margin-top: 20px; }
.fleet-metric-grid { margin-bottom: 20px; }
.vehicle-model { display: flex; align-items: center; gap: 12px; min-width: 240px; }
.vehicle-model img { width: 104px; height: 70px; flex: 0 0 auto; object-fit: contain; border: 1px solid var(--line); border-radius: 10px; background: #f7f8fb; }
.vehicle-model small { display: block; margin-top: 4px; color: var(--blue); font-weight: 800; }

.search-input {
  max-width: 360px;
  margin-top: 0;
}
.client-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.client-card {
  padding: 20px;
}
.client-card h3 {
  margin: 0 0 8px;
  color: var(--navy);
}
.client-card .row-actions { margin-top: 14px; }
.client-card[data-inactive="true"] { opacity: .72; }
.client-filters { align-items: end; }
#clientFeedback[data-state="error"],
#vehicleFeedback[data-state="error"],
#reservationFeedback[data-state="error"],
#contractFeedback[data-state="error"],
#quotesFeedback[data-state="error"] { color: #a12828; }
#clientFeedback[data-state="success"],
#vehicleFeedback[data-state="success"],
#reservationFeedback[data-state="success"],
#contractFeedback[data-state="success"],
#quotesFeedback[data-state="success"] { color: #17643a; }
#contractFeedback[data-state="loading"] { color: var(--navy); }
.financial-section { border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.financial-section legend { color: var(--navy); font-weight: 900; padding: 0 8px; }
.financial-fields, .compact-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.additional-options { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; }
.additional-option { border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: #f8fafc; }
.additional-option input[type="number"] { width: 70px; display: inline-block; margin-left: 8px; }
.financial-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.financial-summary span { padding: 12px; border-radius: 10px; background: #edf4fb; color: var(--navy); font-weight: 800; }
.payment-panel { margin-top: 20px; }
.operation-panel { margin-top: 20px; }
.operation-grid { display: grid; grid-template-columns: minmax(320px, .85fr) minmax(0, 1.15fr); gap: 20px; }
.operation-form { align-content: start; }
.operation-grid h3, .pre-withdrawal h3 { color: var(--navy); }
.pre-withdrawal { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.checklist { display: grid; gap: 8px; padding: 0; list-style: none; }
.checklist li { padding: 10px 12px; border-radius: 10px; background: #e9fbf2; color: #17643a; font-weight: 800; }
.checklist li.pending { background: #fff1f0; color: #a12828; }
.inline-checkbox { width: auto; margin: 0 8px 0 0; }
.admin-exceptions { margin: 14px 0; }
.compact-table { min-width: 560px; }
.comparison-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.comparison-grid article { padding: 14px; border-radius: 12px; background: #edf4fb; color: var(--navy); }
.comparison-grid strong { display: block; margin-top: 5px; }
.inspection-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.inspection-item { padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: #f8fafc; }
.inspection-item small { display: block; color: var(--muted); margin-bottom: 4px; }
.return-form { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.caucao-title { margin-top: 28px; }
.client-card ul {
  margin: 14px 0 0;
  padding-left: 18px;
  color: var(--muted);
}
.export-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.pwa-install-button {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 15;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 52px;
  padding: 13px 19px;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, #1f80d0, #0d5b9b);
  box-shadow: 0 15px 35px rgba(15, 30, 69, .32);
  font-weight: 900;
  cursor: pointer;
}
.pwa-install-button[hidden] { display: none; }
.pwa-install-button span {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: var(--navy);
  background: #fff;
  font-size: 1.15rem;
  line-height: 1;
}
.pwa-install-button:hover { transform: translateY(-2px); }
.pwa-install-help {
  position: fixed;
  right: 24px;
  bottom: 88px;
  z-index: 15;
  width: min(360px, calc(100vw - 36px));
  margin: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--navy2);
  background: #fff;
  box-shadow: var(--shadow);
  font-weight: 800;
  line-height: 1.4;
}
.pwa-install-help[hidden] { display: none; }

.empty-state {
  padding: 22px;
  color: var(--muted);
  text-align: center;
}

#vehicleFeedback:empty,
#clientFeedback:empty,
#reservationFeedback:empty,
#quotesFeedback:empty {
  display: none;
}
.reservation-filters { align-items: end; }
.report-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr)) auto auto;
  align-items: end;
  gap: 14px;
  margin-bottom: 20px;
}
.report-filters .empty-state {
  grid-column: 1 / -1;
  margin: 0;
  padding: 0;
  text-align: left;
}
#vehicleFeedback[data-state="error"] {
  color: var(--red);
}
#vehicleFeedback[data-state="success"] {
  color: var(--green);
}

@media (max-width: 1180px) {
  .metric-grid,
  .report-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .panel-form,
  .client-grid,
  .financial-fields,
  .compact-form,
  .operation-grid,
  .comparison-grid,
  .inspection-grid,
  .financial-summary {
    grid-template-columns: repeat(2, 1fr);
  }
  .fleet-operation-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .panel-page {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
    overflow: visible;
  }
  .panel-nav {
    grid-template-columns: repeat(2, 1fr);
    overflow: visible;
    padding-right: 0;
  }
  .panel-main {
    padding: 22px 18px;
  }
  .panel-top,
  .section-title {
    align-items: flex-start;
    flex-direction: column;
  }
  .metric-grid,
  .report-grid,
  .panel-form,
  .client-grid,
  .operation-grid {
    grid-template-columns: 1fr;
  }
  .fleet-form { grid-template-columns: 1fr; }
  .report-filters { grid-template-columns: 1fr; }
  .request-filters, .details-grid, .status-update-form { grid-template-columns: 1fr; }
  .span-2 {
    grid-column: auto;
  }
}

@media (max-width: 520px) {
  .login-card {
    padding: 22px;
  }
  .login-card h1 {
    font-size: 1.9rem;
  }
  .panel-nav {
    grid-template-columns: 1fr;
  }
  .form-actions,
  .export-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .pwa-install-button { right: 16px; bottom: 16px; }
  .pwa-install-help { right: 16px; bottom: 80px; }
}
