/* =============================================================
   Frota Manager — Operations UI
   Self-contained CSS: no CDN, no build step, system fonts only.
   ============================================================= */

:root,
[data-theme="light"] {
  --space-2xs: 2px;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  --text-xs: 12px;
  --text-sm: 14px;
  --text-md: 16px;
  --text-lg: 18px;
  --text-xl: 24px;
  --text-2xl: 32px;

  --color-bg: #f4f5f2;
  --color-surface: #ffffff;
  --color-surface-raised: #fbfbf8;
  --color-surface-muted: #ecefe9;
  --color-fg: #151816;
  --color-fg-muted: #657069;
  --color-border: #d9ded6;
  --color-border-strong: #bfc8bd;
  --color-nav: rgba(255, 255, 252, 0.94);
  --color-nav-fg: #151816;
  --color-accent: #c9343a;
  --color-accent-hover: #a92c31;
  --color-accent-soft: #f8e7e8;
  --color-success: #1f7a4b;
  --color-success-surface: #e5f4ec;
  --color-warning: #a85f00;
  --color-warning-surface: #fff2d8;
  --color-danger: #ba2f36;
  --color-danger-surface: #fae6e8;
  --color-focus: rgba(201, 52, 58, 0.28);
  --color-overlay: rgba(15, 18, 16, 0.56);

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(20, 26, 22, 0.06);
  --shadow-md: 0 12px 34px rgba(20, 26, 22, 0.10);
  --shadow-lg: 0 24px 72px rgba(20, 26, 22, 0.18);
}

[data-theme="dark"] {
  --color-bg: #101412;
  --color-surface: #191e1b;
  --color-surface-raised: #202721;
  --color-surface-muted: #252d27;
  --color-fg: #edf1ec;
  --color-fg-muted: #a7b0aa;
  --color-border: #354038;
  --color-border-strong: #4b574f;
  --color-nav: rgba(22, 27, 24, 0.94);
  --color-nav-fg: #edf1ec;
  --color-accent: #f17980;
  --color-accent-hover: #ff969b;
  --color-accent-soft: #3a2022;
  --color-success: #79d49e;
  --color-success-surface: #143424;
  --color-warning: #f4bd62;
  --color-warning-surface: #3b2a0d;
  --color-danger: #ff858b;
  --color-danger-surface: #3b171a;
  --color-focus: rgba(241, 121, 128, 0.32);
  --color-overlay: rgba(0, 0, 0, 0.62);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 16px 38px rgba(0, 0, 0, 0.30);
  --shadow-lg: 0 28px 80px rgba(0, 0, 0, 0.42);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0) 340px),
    var(--color-bg);
  color: var(--color-fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: var(--text-md);
  line-height: 1.5;
  letter-spacing: 0;
}

[data-theme="dark"] body {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0) 320px),
    var(--color-bg);
}

button,
input,
select {
  font: inherit;
}

button,
a,
input,
select {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: 12px;
  z-index: 4000;
  transform: translateY(-180%);
  background: var(--color-fg);
  color: var(--color-bg);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  text-decoration: none;
  font-weight: 700;
}

.skip-link:focus {
  transform: translateY(0);
}

/* App shell */

.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  min-height: 72px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(160px, 1fr);
  align-items: center;
  gap: var(--space-lg);
  padding: 12px clamp(16px, 4vw, 40px);
  background: var(--color-nav);
  color: var(--color-nav-fg);
  border-bottom: 1px solid var(--color-border);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  overflow: hidden;
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-copy {
  min-width: 0;
  display: grid;
  gap: var(--space-2xs);
}

.brand-title,
.brand-subtitle {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-title {
  font-size: var(--text-md);
  font-weight: 800;
  line-height: 1.15;
}

.brand-subtitle {
  color: var(--color-fg-muted);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
}

.menu {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  min-width: 0;
  padding: var(--space-xs);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-raised);
  box-shadow: var(--shadow-sm);
}

.menu button,
.bottom-tab-bar button,
.theme-toggle {
  appearance: none;
  border: 0;
}

.menu button {
  width: auto;
  min-height: 40px;
  margin: 0;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-fg-muted);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 800;
  white-space: nowrap;
  transition: background 170ms ease-out, color 170ms ease-out, transform 120ms ease-out;
}

.menu button:hover {
  color: var(--color-fg);
  background: var(--color-surface-muted);
}

.menu button.active {
  color: var(--color-accent);
  background: var(--color-accent-soft);
}

.menu button svg {
  width: 18px;
  height: 18px;
}

.nav-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-sm);
  min-width: 0;
}

.theme-toggle,
.logout-link {
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--color-fg);
  background: transparent;
  text-decoration: none;
  cursor: pointer;
  transition: background 170ms ease-out, transform 120ms ease-out;
}

.theme-toggle {
  width: 44px;
  height: 44px;
  padding: 0;
}

.theme-toggle:hover,
.logout-link:hover {
  background: var(--color-surface-muted);
}

.theme-toggle:active,
.logout-link:active,
button:active {
  transform: translateY(1px);
}

.theme-toggle svg,
.logout-link svg {
  width: 20px;
  height: 20px;
}

.logout-link {
  padding: 0 12px;
  font-size: var(--text-sm);
  font-weight: 800;
}

/* Admin overflow menu — desktop hides it (the header .menu already exposes
   Gestão/Estatísticas); shown only on mobile where .menu is hidden so an
   admin/gestor can still reach those panels on a phone. */
.admin-menu {
  display: none;
  position: relative;
}

.admin-menu-toggle {
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 12px;
  color: var(--color-fg);
  background: transparent;
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 800;
  transition: background 170ms ease-out;
}

.admin-menu-toggle:hover {
  background: var(--color-surface-muted);
}

.admin-menu-list {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 1100;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
}

.admin-menu-list[hidden] {
  display: none;
}

.admin-menu-list button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-fg);
  font-size: var(--text-sm);
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.admin-menu-list button:hover {
  background: var(--color-surface-muted);
}

.admin-menu-list button.active {
  color: var(--color-accent);
  background: var(--color-accent-soft);
}

.admin-menu-list button svg {
  flex: 0 0 auto;
}

.bottom-tab-bar {
  display: none;
}

.content {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 104px 0 56px;
}

.panel {
  display: block;
  min-width: 0;
}

.panel-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.eyebrow {
  margin: 0 0 var(--space-xs);
  color: var(--color-accent);
  font-size: var(--text-xs);
  font-weight: 900;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: var(--space-sm);
  color: var(--color-fg);
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 850;
  line-height: 1.08;
}

h2 {
  margin-bottom: 0;
  color: var(--color-fg);
  font-size: var(--text-lg);
  font-weight: 850;
  line-height: 1.2;
}

.panel-copy,
.section-header p,
.login-card-header p,
.login-hero p {
  margin-bottom: 0;
  color: var(--color-fg-muted);
}

.panel-copy {
  max-width: 700px;
  font-size: var(--text-md);
}

.reservation-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  gap: var(--space-lg);
  align-items: start;
}

.booking-card,
.reservation-list-panel,
.trips-panel #viagens-list,
.user-create-card,
.user-list-panel,
.registry-toolbar,
.registry-table-wrap,
.user-table-wrap,
.registry-card,
.user-card,
.trip-card,
.confirm-dialog,
.login-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.booking-card,
.reservation-list-panel,
.trips-panel #viagens-list,
.user-create-card,
.user-list-panel {
  padding: var(--space-lg);
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.section-header p {
  margin-top: var(--space-xs);
  font-size: var(--text-sm);
}

label {
  display: block;
  margin: 16px 0 6px;
  color: var(--color-fg);
  font-size: var(--text-sm);
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 48px;
  padding: 11px 12px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface-raised);
  color: var(--color-fg);
  font-size: var(--text-md);
  transition: border-color 170ms ease-out, box-shadow 170ms ease-out, background 170ms ease-out;
}

input::placeholder {
  color: var(--color-fg-muted);
}

input:hover,
select:hover {
  border-color: var(--color-fg-muted);
}

input:focus,
select:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 4px var(--color-focus);
  outline: 0;
}

input.invalid,
select.invalid {
  border-color: var(--color-danger);
}

.field-error {
  display: none;
  margin: 4px 0 0;
  color: var(--color-danger);
  font-size: var(--text-sm);
  font-weight: 700;
}

.time-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-md);
}

.form-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
}

button,
.btn-primary,
.btn-secondary,
.btn-success,
.btn-danger,
.btn-small {
  min-height: 44px;
  border: 0;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: var(--text-md);
  font-weight: 850;
  text-decoration: none;
  transition: background 170ms ease-out, border-color 170ms ease-out, color 170ms ease-out, transform 120ms ease-out, opacity 170ms ease-out;
}

.btn-primary,
.btn-secondary,
.btn-success,
.btn-danger {
  width: auto;
  padding: 0 16px;
}

.btn-primary {
  background: var(--color-accent);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-accent-hover);
}

.btn-secondary {
  background: var(--color-surface-muted);
  color: var(--color-fg);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-border);
}

.btn-success {
  background: var(--color-success);
  color: #ffffff;
}

.btn-danger {
  background: var(--color-danger);
  color: #ffffff;
}

.btn-danger:hover:not(:disabled) {
  background: var(--color-accent-hover);
}

.btn-small {
  width: auto;
  min-height: 36px;
  padding: 0 12px;
  font-size: var(--text-sm);
}

button:disabled,
.btn-primary:disabled,
.btn-secondary:disabled,
.btn-success:disabled,
.btn-danger:disabled {
  cursor: not-allowed;
  opacity: 0.62;
  transform: none;
}

button svg,
.btn-primary svg,
.btn-secondary svg {
  flex: 0 0 auto;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.btn-spinner {
  width: 16px;
  height: 16px;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

.alert {
  display: none;
  margin-top: var(--space-md);
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 800;
  border: 1px solid transparent;
}

.alert.success {
  background: var(--color-success-surface);
  color: var(--color-success);
  border-color: rgba(31, 122, 75, 0.20);
}

.alert.error {
  background: var(--color-danger-surface);
  color: var(--color-danger);
  border-color: rgba(186, 47, 54, 0.20);
}

#check-result:not(:empty) {
  display: block;
}

#check-result {
  text-align: center;
}

.trip-card {
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  box-shadow: none;
  transition: border-color 180ms ease-out, background 180ms ease-out, transform 180ms ease-out;
}

.trip-card:last-child {
  margin-bottom: 0;
}

.trip-card:hover {
  border-color: var(--color-border-strong);
}

.trip-card.incompleta-card {
  border-color: var(--color-accent);
  background: linear-gradient(180deg, var(--color-surface) 0%, var(--color-accent-soft) 220%);
}

.trip-card-head,
.registry-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-sm);
}

.trip-vehicle {
  color: var(--color-fg);
  font-size: var(--text-md);
  font-weight: 850;
  line-height: 1.25;
}

.trip-status-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-xs);
}

.trip-route {
  color: var(--color-fg);
  font-weight: 650;
}

.trip-window,
.trip-km-summary,
.registry-meta,
.registry-meta small {
  color: var(--color-fg-muted);
  font-size: var(--text-sm);
}

.trip-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: var(--space-sm);
}

.trip-card .trip-km-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-md);
  margin-top: var(--space-md);
}

.trip-card .trip-km-row label {
  margin-top: 0;
}

.trip-card .trip-km-row input {
  min-height: 52px;
  font-size: 20px;
  font-weight: 850;
}

.trip-card .btn-primary {
  width: 100%;
  min-height: 48px;
  margin-top: var(--space-md);
}

.trip-conclusa {
  background: var(--color-surface-raised);
}

.trip-conclusa .trip-km-summary {
  margin-top: var(--space-sm);
  font-weight: 700;
}

.badge-atraso,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 850;
  line-height: 1;
  white-space: nowrap;
}

.badge-atraso {
  background: var(--color-danger);
  color: #ffffff;
}

.status-pill {
  background: var(--color-surface-muted);
  color: var(--color-fg-muted);
}

.status-pill.incompleta {
  background: var(--color-warning-surface);
  color: var(--color-warning);
}

.status-pill.concluida {
  background: var(--color-success-surface);
  color: var(--color-success);
}

.status-pill.cancelada {
  background: var(--color-surface-muted);
  color: var(--color-fg-muted);
}

.viagens-section-label {
  margin: var(--space-md) 0 var(--space-sm);
  color: var(--color-fg-muted);
  font-size: var(--text-xs);
  font-weight: 900;
  text-transform: uppercase;
}

.viagens-section-label:first-child {
  margin-top: 0;
}

.section-divider {
  border: 0;
  border-top: 1px solid var(--color-border);
  margin: var(--space-lg) 0;
}

.registry-panel {
  width: min(1280px, 100%);
  margin-inline: auto;
}

.registry-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto;
  gap: var(--space-md);
  align-items: end;
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

.registry-toolbar label {
  margin-top: 0;
}

.registry-toolbar button {
  white-space: nowrap;
}

.registry-table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 940px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--text-sm);
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--color-surface-raised);
  color: var(--color-fg-muted);
  font-size: var(--text-xs);
  font-weight: 900;
  text-transform: uppercase;
}

.registry-table td:nth-child(7),
.registry-table td:nth-child(8) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

tr:last-child td {
  border-bottom: 0;
}

.registry-table .muted-row {
  background: var(--color-surface-muted);
  color: var(--color-fg-muted);
}

.registry-cards {
  display: none;
}

.registry-card {
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  box-shadow: none;
}

.registry-card.cancelada {
  background: var(--color-surface-muted);
}

.registry-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: var(--space-sm);
}

.users-panel {
  width: min(1280px, 100%);
  margin-inline: auto;
}

.users-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: var(--space-lg);
  align-items: start;
}

.user-create-card .btn-primary {
  width: 100%;
  margin-top: var(--space-lg);
}

.user-active-row {
  margin-top: var(--space-md);
}

.user-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.user-table {
  min-width: 980px;
}

.user-table td {
  vertical-align: top;
}

.user-table td:first-child {
  min-width: 150px;
}

.user-table td:nth-child(2) {
  min-width: 190px;
}

.user-table td:nth-child(3),
.user-table td:nth-child(4) {
  min-width: 140px;
}

.user-table td:nth-child(5) {
  min-width: 180px;
}

.user-table td:nth-child(6) {
  min-width: 140px;
  color: var(--color-fg-muted);
  font-size: var(--text-sm);
}

.user-table input,
.user-table select {
  min-height: 42px;
  font-size: var(--text-sm);
}

.user-table-check {
  margin: 0;
}

.user-table-check input,
.user-active-row input {
  width: 18px;
  min-width: 18px;
}

.user-cards {
  display: none;
}

.user-card {
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  box-shadow: none;
}

.user-card:last-child {
  margin-bottom: 0;
}

.user-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.user-card .btn-primary {
  width: 100%;
  margin-top: var(--space-md);
}

.toast {
  position: fixed;
  top: 86px;
  left: 50%;
  z-index: 2000;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: min(420px, calc(100% - 32px));
  padding: 13px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: var(--text-sm);
  font-weight: 750;
  opacity: 0;
  transform: translateX(-50%) translateY(-10px);
  animation: toast-in 200ms ease-out forwards;
}

.toast.toast-success {
  background: var(--color-success-surface);
  color: var(--color-success);
  border-color: rgba(31, 122, 75, 0.20);
}

.toast.toast-error {
  background: var(--color-danger-surface);
  color: var(--color-danger);
  border-color: rgba(186, 47, 54, 0.20);
}

.toast-message {
  flex: 1;
}

.toast-close {
  width: 28px;
  min-width: 28px;
  min-height: 28px;
  padding: 0;
  margin: -4px -4px 0 0;
  background: transparent;
  color: inherit;
  opacity: 0.72;
}

.toast-close:hover {
  opacity: 1;
}

.toast-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  to {
    opacity: 0;
    transform: translateX(-50%) translateY(-8px);
  }
}

.toast.toast-exiting {
  animation: toast-out 150ms ease-in forwards;
}

.skeleton-bar {
  height: 16px;
  margin-bottom: 10px;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--color-surface-muted), var(--color-border), var(--color-surface-muted));
  background-size: 220% 100%;
  animation: skeleton-sweep 1.25s ease-in-out infinite;
}

@keyframes skeleton-sweep {
  0% {
    background-position: 120% 0;
  }
  100% {
    background-position: -120% 0;
  }
}

.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  background: var(--color-overlay);
  opacity: 0;
  animation: fade-in 150ms ease-out forwards;
}

@keyframes fade-in {
  to {
    opacity: 1;
  }
}

.confirm-dialog {
  width: min(420px, 100%);
  padding: var(--space-lg);
  box-shadow: var(--shadow-lg);
}

.confirm-dialog h3 {
  margin-bottom: var(--space-sm);
  color: var(--color-fg);
  font-size: var(--text-xl);
  font-weight: 850;
  line-height: 1.2;
}

.confirm-dialog p {
  margin-bottom: var(--space-lg);
  color: var(--color-fg-muted);
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 180px;
  padding: var(--space-lg);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-md);
  color: var(--color-fg-muted);
  text-align: center;
}

.empty-state svg {
  width: 46px;
  height: 46px;
  margin-bottom: var(--space-md);
  color: var(--color-fg-muted);
}

.empty-state h3 {
  margin-bottom: var(--space-xs);
  color: var(--color-fg);
  font-size: var(--text-md);
  font-weight: 850;
}

.empty-state p {
  margin-bottom: 0;
  font-size: var(--text-sm);
}

/* Login */

body.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(20px, 5vw, 64px);
  background:
    linear-gradient(135deg, rgba(13, 18, 15, 0.96) 0%, rgba(34, 44, 38, 0.94) 48%, rgba(151, 43, 49, 0.95) 100%);
  color: #ffffff;
}

.login-container {
  width: min(1040px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.75fr);
  gap: clamp(24px, 5vw, 64px);
  align-items: center;
}

.login-hero {
  min-width: 0;
}

.login-hero .eyebrow {
  color: #ffb3b8;
}

.login-hero h1 {
  max-width: 620px;
  color: #ffffff;
  font-size: clamp(36px, 6vw, 64px);
}

.login-hero p {
  max-width: 560px;
  color: rgba(255, 255, 255, 0.78);
  font-size: var(--text-lg);
}

.login-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  max-width: 100%;
  min-height: 0;
  margin-bottom: var(--space-lg);
  padding: 14px 22px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.20);
}

.login-logo img {
  display: block;
  width: clamp(240px, 28vw, 320px);
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

.login-card {
  padding: clamp(24px, 4vw, 36px);
  background: rgba(255, 255, 255, 0.94);
  color: #171b18;
  box-shadow: var(--shadow-lg);
}

[data-theme="dark"] .login-card {
  background: rgba(25, 30, 27, 0.94);
  color: var(--color-fg);
}

.login-card-header {
  margin-bottom: var(--space-lg);
}

.login-card-header .eyebrow {
  color: var(--color-accent);
}

.login-card-header h2 {
  margin-bottom: var(--space-xs);
  font-size: var(--text-xl);
}

.login-card .form-group {
  margin-bottom: var(--space-md);
}

.login-card label {
  color: currentColor;
}

.login-card input[type="text"],
.login-card input[type="password"] {
  background: rgba(255, 255, 255, 0.86);
  color: #171b18;
}

[data-theme="dark"] .login-card input[type="text"],
[data-theme="dark"] .login-card input[type="password"] {
  background: var(--color-surface-raised);
  color: var(--color-fg);
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  margin: var(--space-sm) 0 var(--space-lg);
}

.checkbox-row input[type="checkbox"] {
  width: 18px;
  min-width: 18px;
  height: 18px;
  min-height: 18px;
  margin: 3px 0 0;
  accent-color: var(--color-accent);
}

.checkbox-row label {
  margin: 0;
  color: inherit;
  font-weight: 650;
  cursor: pointer;
}

.login-card .btn-primary {
  width: 100%;
  min-height: 48px;
}

.login-alert {
  margin-bottom: var(--space-md);
  padding: 12px 14px;
  border: 1px solid rgba(186, 47, 54, 0.24);
  border-radius: var(--radius-md);
  background: var(--color-danger-surface);
  color: var(--color-danger);
  font-size: var(--text-sm);
  font-weight: 800;
}

.theme-toggle--fixed {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
  color: #ffffff;
}

.theme-toggle--fixed:hover {
  background: rgba(255, 255, 255, 0.12);
}

@media (max-width: 980px) {
  .top-bar {
    grid-template-columns: minmax(180px, 1fr) auto;
  }

  .top-bar .menu {
    display: none;
  }

  /* .menu is hidden here, so expose the admin/gestor overflow menu in the
     header instead — keeps Gestão/Estatísticas reachable on a phone while
     the bottom bar stays at the 4 staff-critical tabs. */
  .admin-menu {
    display: block;
  }

  .bottom-tab-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    height: calc(64px + env(safe-area-inset-bottom, 0px));
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--color-border);
    background: var(--color-nav);
    backdrop-filter: blur(18px) saturate(160%);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
  }

  .bottom-tab-bar button {
    flex: 1;
    min-width: 0;
    min-height: 52px;
    margin: 0;
    padding: 4px 6px;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--color-fg-muted);
    cursor: pointer;
    flex-direction: column;
    gap: 2px;
    font-size: var(--text-xs);
    font-weight: 850;
  }

  .bottom-tab-bar button.active {
    color: var(--color-accent);
    background: var(--color-accent-soft);
  }

  .bottom-tab-bar button svg {
    width: 22px;
    height: 22px;
  }

  .content {
    padding-bottom: 96px;
  }

  .reservation-layout,
  .users-layout,
  .login-container {
    grid-template-columns: 1fr;
  }

  .login-hero {
    text-align: left;
  }
}

@media (max-width: 720px) {
  body {
    background: var(--color-bg);
  }

  .top-bar {
    min-height: 64px;
    padding: 10px 14px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
  }

  .brand-subtitle {
    display: none;
  }

  .logout-link {
    width: 44px;
    padding: 0;
  }

  .logout-link span {
    font-size: 0;
  }

  .logout-link svg {
    margin: 0;
  }

  /* Collapse the overflow menu to an icon-only tap target to keep the header
     uncluttered at phone width (the aria-label keeps it accessible). */
  .admin-menu-toggle {
    width: 44px;
    padding: 0;
  }

  .admin-menu-label {
    display: none;
  }

  .content {
    width: min(100% - 24px, 1180px);
    padding-top: 88px;
  }

  .panel-header {
    margin-bottom: var(--space-md);
  }

  h1 {
    font-size: 30px;
  }

  .booking-card,
  .reservation-list-panel,
  .trips-panel #viagens-list,
  .user-create-card,
  .user-list-panel {
    padding: var(--space-md);
  }

  .form-actions,
  .time-row,
  .trip-card .trip-km-row,
  .confirm-actions {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .form-actions .btn-primary,
  .form-actions .btn-secondary,
  .confirm-actions button {
    width: 100%;
  }

  .trip-card-head,
  .registry-card-head {
    align-items: flex-start;
    flex-direction: column;
    gap: var(--space-sm);
  }

  .trip-status-group {
    justify-content: flex-start;
  }

  .registry-toolbar {
    grid-template-columns: 1fr;
  }

  .registry-toolbar button {
    width: 100%;
  }

  .registry-table-wrap {
    display: none;
  }

  .registry-cards {
    display: block;
  }

  .user-table-wrap {
    display: none;
  }

  .user-cards {
    display: block;
  }

  body.login-page {
    align-items: flex-start;
    padding: 80px 16px 24px;
  }

  .login-hero h1 {
    font-size: 36px;
  }

  .login-hero p {
    font-size: var(--text-md);
  }

  .login-logo {
    padding: 12px 18px;
  }

  .login-logo img {
    width: min(260px, 100%);
  }
}

@media (max-width: 420px) {
  .brand-copy {
    max-width: 150px;
  }

  .nav-actions {
    gap: 4px;
  }

  .content {
    width: min(100% - 16px, 1180px);
  }

  h1 {
    font-size: 28px;
  }
}

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

  .skeleton-bar {
    animation: none;
  }
}

/* ── Fuel logging UI ─────────────────────────────────────────────────────── */

.fuel-section {
  margin-top: var(--space-md);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--color-border);
}

.fuel-list {
  margin-bottom: var(--space-sm);
}

.fuel-log-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs, 4px);
  padding: var(--space-xs, 4px) 0;
  font-size: var(--text-sm);
  border-bottom: 1px dashed var(--color-border);
  color: var(--color-fg-muted);
}

.fuel-log-item:last-child {
  border-bottom: none;
}

.fuel-receipt-link {
  font-size: var(--text-sm);
  color: var(--color-primary);
  text-decoration: underline;
}

.fuel-empty {
  font-size: var(--text-sm);
  color: var(--color-fg-muted);
  margin: 0 0 var(--space-sm);
}

.fuel-add-toggle {
  margin-top: var(--space-xs, 4px);
}

.fuel-form {
  margin-top: var(--space-sm);
  padding: var(--space-sm);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md, 8px);
}

.fuel-form .trip-km-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-md);
  margin-top: 0;
}

.fuel-form label {
  display: block;
  font-size: var(--text-sm);
  margin-bottom: 4px;
  color: var(--color-fg-muted);
}

.fuel-form input[type="text"],
.fuel-form input[type="file"] {
  width: 100%;
  box-sizing: border-box;
}

.fuel-form .btn-primary {
  width: 100%;
  min-height: 44px;
  margin-top: var(--space-md);
}

.fuel-col {
  font-size: var(--text-sm);
  min-width: 120px;
}

.registry-fuel-panel {
  margin-top: var(--space-sm);
  padding: var(--space-sm);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md, 8px);
}

/* =============================================================
   Calendário — day-grid availability (Phase 7, CAL-01/CAL-02)
   Tokens only; weights restricted to 400/800; dark theme free.
   ============================================================= */

#calendario-grid {
  margin-top: var(--space-md);
  /* WR-03: a grelha mostra agora as 24 horas (00–23) para que reservas fora
     da banda 08–20 deixem de parecer disponibilidade. Tornar a grelha rolável
     verticalmente para não ocupar toda a página no telemóvel. */
  max-height: 70vh;
  overflow-y: auto;
}

.calendario-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  margin-top: var(--space-md);
  padding: var(--space-sm);
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.cal-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: var(--space-xs);
  background: var(--color-surface);
  color: var(--color-fg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 800;
}

.cal-nav-btn:hover:not(:disabled) {
  box-shadow: var(--shadow-sm);
}

.cal-nav-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--color-focus);
}

.cal-nav-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.cal-day-label {
  min-width: 140px;
  text-align: center;
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--color-accent);
}

.calendario-grid-inner {
  display: grid;
  /* Rows are at least 44px (uniform free/past cells) but expand to fit an
     occupied cell's booker name + destination + time so the details stay
     legible instead of being clipped (RES-07). */
  grid-auto-rows: minmax(44px, auto);
  gap: var(--space-xs);
  margin-top: var(--space-md);
  width: 100%;
}

.cal-corner {
  background: transparent;
}

.cal-col-head {
  padding: var(--space-xs);
  text-align: center;
  font-size: var(--text-xs);
  font-weight: 800;
  color: var(--color-fg);
  background: var(--color-surface-muted);
  border-radius: var(--radius-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cal-hour-label {
  display: flex;
  align-self: start;
  justify-content: flex-end;
  padding-right: var(--space-xs);
  font-size: var(--text-xs);
  font-weight: 800;
  color: var(--color-fg-muted);
  white-space: nowrap;
  transform: translateY(-50%);
}

.cal-cell {
  min-height: 44px;
  border-radius: var(--radius-sm);
  box-sizing: border-box;
}

.cal-free {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  cursor: pointer;
}

.cal-free:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--color-border-strong);
}

.cal-free:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
  box-shadow: 0 0 0 4px var(--color-focus);
}

.cal-occupied {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
  padding: var(--space-xs);
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-border-strong);
  overflow: hidden;
}

.cal-occ-name {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-fg);
  line-height: 1.2;
  /* Wrap instead of single-line ellipsis so the booker name is not clipped
     in a narrow phone column; the row grows to fit (RES-07). */
  overflow-wrap: anywhere;
}

.cal-occ-dest {
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--color-fg);
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.cal-occ-time {
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--color-fg-muted);
  line-height: 1.2;
}

.cal-past {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  opacity: 0.55;
}

.cal-empty {
  margin-top: var(--space-md);
}

/* =============================================================
   Gestão + Estatísticas (Phase 8)
   ============================================================= */

/* Subtab switcher (Registo → Histórico / Estatísticas) */
.subtab-switcher {
  display: flex;
  gap: var(--space-xs);
  padding: var(--space-2xs);
  margin-bottom: var(--space-lg);
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  width: fit-content;
  max-width: 100%;
}

.subtab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--color-fg-muted);
  font-size: var(--text-sm);
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}

.subtab svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.subtab:hover {
  color: var(--color-fg);
}

.subtab.active {
  background: var(--color-surface);
  color: var(--color-accent);
  box-shadow: var(--shadow-sm);
}

.subtab:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

@media (max-width: 480px) {
  .subtab-switcher {
    width: 100%;
  }
  .subtab {
    flex: 1;
    justify-content: center;
  }
}

.gestao-section {
  margin-bottom: var(--space-2xl);
}

.gestao-section:last-child {
  margin-bottom: 0;
}

.dashboard-period {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.dashboard-presets {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.dashboard-presets .active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}

.dashboard-custom {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-sm);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-lg);
}

.dashboard-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
}

#dashboard-chart {
  width: 100%;
}

.trend-chart {
  display: block;
  width: 100%;
  height: auto;
}

.dashboard-destinations-list {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: dest;
}

.dashboard-destinations-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--color-border);
}

.dashboard-destinations-list li:last-child {
  border-bottom: none;
}

.dashboard-destinations-list li::before {
  counter-increment: dest;
  content: counter(dest) ".";
  color: var(--color-fg-muted);
  font-variant-numeric: tabular-nums;
}

.dashboard-destinations-list li span {
  flex: 1;
}
