:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #64748b;
  --line: #dbe3ea;
  --brand: #176b87;
  --brand-dark: #0f4f63;
  --accent: #c77d1f;
  --danger: #b42318;
  --danger-bg: #fee4e2;
  --ok: #147a4b;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: clip;
  max-width: 100%;
}

body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea,
.link-button {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  min-height: 40px;
  padding: 0 14px;
  font-weight: 700;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: wait;
  opacity: 0.68;
}

.primary {
  background: var(--brand);
  color: white;
}

.primary:hover {
  background: var(--brand-dark);
}

.secondary {
  background: #dff0f5;
  color: var(--brand-dark);
}

.ghost {
  background: transparent;
  color: var(--brand-dark);
  border: 1px solid var(--line);
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  flex: 0 0 auto;
}

.topbar-actions form,
.topbar > form {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  width: 100%;
  max-width: 100%;
  min-width: 0;
  flex-wrap: wrap;
}

.topbar h1,
.login-panel h1 {
  margin: 0;
  font-size: clamp(18px, 2.2vw, 24px);
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
  flex: 1 1 320px;
}

.brand-copy {
  flex: 1 1 180px;
  min-width: 0;
}

.topbar .brand-block {
  align-items: center;
}

.topbar .brand-logo-shell {
  padding: 8px 14px;
  flex-shrink: 0;
}

.topbar .brand-logo-freedrive {
  width: 190px;
  max-width: 100%;
  height: auto;
  aspect-ratio: 220 / 72;
}

.brand-logo {
  width: 180px;
  height: 92px;
  object-fit: contain;
  flex: 0 0 auto;
}

.brand-logo-freedrive {
  width: 220px;
  max-width: 100%;
  height: auto;
  aspect-ratio: 220 / 72;
}

.brand-logo-shell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #000;
  border-radius: 8px;
  padding: 10px 16px;
  flex: 0 0 auto;
  max-width: 100%;
}

.login-panel .brand-logo-shell {
  padding: 12px 18px;
}

.login-brand.brand-block {
  flex-direction: column;
  justify-content: center;
  text-align: center;
  gap: 12px;
  margin-bottom: 20px;
}

.login-brand.brand-block > .brand-copy {
  min-width: 0;
  width: 100%;
}

.login-panel .brand-logo-freedrive {
  width: min(240px, 100%);
  height: auto;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  max-width: 100%;
  padding: 0 10px;
  margin-right: 0;
  border-radius: 999px;
  background: #eef4f6;
  color: var(--muted);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layout {
  width: 100%;
  max-width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px 32px 48px;
  min-width: 0;
}

.loading-status {
  position: sticky;
  top: 12px;
  z-index: 20;
  display: none;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #b9d8e2;
  border-radius: 8px;
  background: #f0f9fc;
  color: var(--brand-dark);
  box-shadow: var(--shadow);
}

.loading-status.active {
  display: flex;
}

.loading-status strong {
  font-size: 14px;
}

.loading-status span:last-child {
  color: var(--muted);
  font-size: 13px;
}

.spinner {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border: 3px solid rgba(23, 107, 135, 0.22);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner.small {
  width: 14px;
  height: 14px;
  border-width: 2px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.toolbar,
.alerts-band,
.report-panel,
.form-panel,
.table-wrap {
  margin-top: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.report-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
  gap: 18px;
}

.report-panel {
  padding: 18px;
}

.bar-chart {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(72px, 88px) minmax(0, 1fr) minmax(72px, 112px);
  gap: 12px;
  align-items: center;
}

.bar-row span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.bar-row strong {
  text-align: right;
  font-size: 13px;
}

.bar-track {
  height: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: #eef2f5;
}

.bar-track i {
  display: block;
  height: 100%;
  min-width: 3%;
  border-radius: inherit;
}

.bar-track .positive,
.bar-track .revenue {
  background: #147a4b;
}

.bar-track .negative,
.bar-track .expense {
  background: #b42318;
}

.bar-track .days {
  background: #7a5c12;
}

.comparison-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.skeleton-row span,
.skeleton-row strong,
.skeleton-card strong,
.skeleton-card span {
  display: block;
  min-height: 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, #eef2f5 25%, #f8fafc 45%, #eef2f5 65%);
  background-size: 240% 100%;
  animation: shimmer 1.1s ease-in-out infinite;
}

.skeleton-row span {
  width: 74px;
}

.skeleton-row strong {
  width: 88px;
}

.skeleton-row .bar-track i {
  background: linear-gradient(90deg, #d8e5ea 25%, #f8fafc 45%, #d8e5ea 65%);
  background-size: 240% 100%;
  animation: shimmer 1.1s ease-in-out infinite;
}

.skeleton-card strong {
  width: 180px;
}

.skeleton-card span {
  width: min(280px, 80%);
  margin-top: 10px;
}

@keyframes shimmer {
  0% {
    background-position: 140% 0;
  }

  100% {
    background-position: -140% 0;
  }
}

.toolbar {
  padding: 14px;
}

.filters {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  width: 100%;
  min-width: 0;
}

.filters label {
  flex: 1 1 140px;
  min-width: 0;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--text);
  padding: 10px 11px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(23, 107, 135, 0.14);
}

.vehicle-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  width: 100%;
}

.vehicle-picker .vehicle-search {
  border-radius: 8px 0 0 8px;
}

.vehicle-picker-toggle {
  min-height: 42px;
  padding: 0;
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 0 8px 8px 0;
  background: #eef4f6;
  color: var(--brand-dark);
  font-size: 16px;
}

.vehicle-picker:focus-within .vehicle-picker-toggle {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(23, 107, 135, 0.14);
}

.alerts-band {
  padding: 18px;
}

.alerts-priority {
  margin-top: 0;
  border-color: #f0c36d;
}

h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

.alerts-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 10px;
}

.alert-item {
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: 8px;
  padding: 12px;
  background: #fffaf1;
}

.alert-item.expired {
  border-left-color: var(--danger);
  background: var(--danger-bg);
}

.alert-item strong,
.alert-item span {
  display: block;
}

.alert-item span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.app-menu {
  display: flex;
  gap: 8px;
  margin-top: 22px;
  flex-wrap: wrap;
}

.menu-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  text-decoration: none;
  font-weight: 800;
}

.menu-link.active {
  background: #e6f3f7;
  color: var(--brand-dark);
  border-color: #a9cfd9;
}

.mobile-menu {
  display: none;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.mobile-menu summary {
  min-height: 48px;
  padding: 13px 14px;
  color: var(--brand-dark);
  font-weight: 900;
  cursor: pointer;
}

.menu-list {
  display: grid;
  gap: 8px;
  padding: 0 12px 12px;
}

.page-panel {
  display: none;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.page-panel.active {
  display: block;
}

.layout:not([data-page="fleet"]):not([data-page="dashboard"]) #dashboard,
.layout:not([data-page="fleet"]):not([data-page="dashboard"]) #fleet {
  display: none !important;
}

.layout:not([data-page="fleet"]) .dashboard-tools {
  display: none !important;
}

#dashboard > .toolbar {
  margin-top: 0;
}

#dashboard > .summary-grid {
  margin-top: 18px;
}

#customers > .customers-toolbar {
  margin-top: 0;
}

.two-column.active {
  display: grid;
  grid-template-columns: minmax(0, 480px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.form-panel {
  padding: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.stack {
  display: grid;
  gap: 14px;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.table-wrap,
.compact-table-wrap {
  overflow-x: clip;
  max-width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 0;
}

.responsive-table {
  table-layout: fixed;
}

.responsive-table th,
.responsive-table td {
  overflow-wrap: anywhere;
  word-break: break-word;
}

th,
td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

td {
  font-size: 14px;
}

.loading-row td {
  color: var(--muted);
  font-weight: 700;
}

.loading-row td {
  display: table-cell;
}

.loading-row .spinner {
  display: inline-block;
  margin-right: 8px;
  vertical-align: -2px;
}

.money-positive {
  color: var(--ok);
  font-weight: 800;
}

.money-negative {
  color: var(--danger);
  font-weight: 800;
}

.muted-text {
  color: var(--muted);
}

.status-pill,
.alert-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin: 0 6px 6px 0;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.available {
  background: #e7f6ee;
  color: #12633d;
}

.status-pill.unavailable {
  background: #fff2d9;
  color: #7a4b00;
}

.alert-badge.soon {
  background: #fff2d9;
  color: #7a4b00;
}

.alert-badge.expired {
  background: var(--danger-bg);
  color: var(--danger);
}

.range-separator {
  display: inline-block;
  width: 14px;
  height: 2px;
  margin: 0 7px;
  border-radius: 999px;
  background: var(--muted);
  vertical-align: middle;
}

.inline-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  vertical-align: middle;
}

.empty-icon::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid var(--muted);
  border-radius: 50%;
}

.empty-icon::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 2px;
  border-radius: 999px;
  background: var(--muted);
  transform: rotate(-45deg);
}

.inline-icon {
  position: relative;
}

.open-icon::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid var(--accent);
  border-right-color: transparent;
  border-radius: 50%;
}

.open-icon::after {
  content: "";
  position: absolute;
  right: 4px;
  top: 4px;
  width: 6px;
  height: 6px;
  border-top: 2px solid var(--accent);
  border-right: 2px solid var(--accent);
  transform: rotate(45deg);
}

.row-action {
  min-height: 32px;
  padding: 0 10px;
  background: #eef4f6;
  color: var(--brand-dark);
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  background: white;
  color: var(--brand-dark);
}

.chart-button {
  gap: 3px;
  align-items: end;
  padding-bottom: 8px;
}

.chart-button span {
  display: block;
  width: 4px;
  border-radius: 999px 999px 0 0;
  background: var(--brand);
}

.chart-button span:nth-child(1) {
  height: 8px;
}

.chart-button span:nth-child(2) {
  height: 14px;
}

.chart-button span:nth-child(3) {
  height: 20px;
  background: var(--accent);
}

.chart-button:hover,
.icon-button:hover {
  border-color: var(--brand);
  background: #eef8fb;
}

.edit-button {
  position: relative;
}

.edit-button span:first-child {
  width: 15px;
  height: 5px;
  border-radius: 999px;
  background: var(--brand);
  transform: rotate(-38deg);
}

.edit-button span:last-child {
  position: absolute;
  right: 9px;
  bottom: 9px;
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 6px solid var(--accent);
  transform: rotate(-38deg);
}

.back-button {
  position: relative;
  text-decoration: none;
}

.back-button::before {
  content: "";
  width: 12px;
  height: 12px;
  border-left: 3px solid var(--brand);
  border-bottom: 3px solid var(--brand);
  transform: rotate(45deg);
  margin-left: 4px;
}

.report-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 160px;
  color: var(--muted);
  font-weight: 800;
}

.report-page-body {
  margin-top: 18px;
}

.report-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.report-summary-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #f8fafc;
}

.report-summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.report-summary-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
}

.vehicle-report-section {
  margin-top: 18px;
}

.vehicle-report-section h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.timeline {
  display: grid;
  gap: 8px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) 100px;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-left: 5px solid var(--brand);
  border-radius: 8px;
  padding: 10px 12px;
  background: white;
}

.timeline-item.expense {
  border-left-color: var(--danger);
}

.timeline-item time,
.timeline-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.timeline-item strong,
.timeline-item span {
  display: block;
}

.timeline-item b {
  text-align: right;
}

.report-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.compact-table-wrap {
  overflow-x: clip;
  border: 1px solid var(--line);
  border-radius: 8px;
  max-width: 100%;
}

.compact-table-wrap table {
  min-width: 0;
}

.form-panel.busy {
  position: relative;
}

.form-panel.busy::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 8px;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.36);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(360px, calc(100% - 44px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #10212b;
  color: white;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #eef6f8, #f8f3ea);
}

.login-shell {
  width: min(480px, calc(100% - 32px));
}

.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.alert.error {
  margin: 18px 0;
  padding: 12px;
  border-radius: 8px;
  background: var(--danger-bg);
  color: var(--danger);
  font-weight: 700;
}

@media (max-width: 980px) {
  .topbar {
    padding: 16px 18px;
    gap: 14px;
  }

  .brand-block {
    flex: 1 1 100%;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
  }

  .brand-copy {
    width: 100%;
  }

  .topbar .brand-logo-shell {
    width: min(300px, 100%);
    padding: 10px 16px;
  }

  .topbar .brand-logo-freedrive {
    width: 100%;
    max-width: 260px;
  }

  .topbar h1 {
    font-size: 20px;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
    border-top: 1px solid var(--line);
    padding-top: 12px;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .report-grid,
  .comparison-grid {
    grid-template-columns: 1fr;
  }

  .report-summary-grid,
  .report-detail-grid {
    grid-template-columns: 1fr;
  }

  .two-column.active {
    grid-template-columns: 1fr;
  }

  .responsive-table thead {
    display: none;
  }

  .responsive-table tbody tr {
    display: block;
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    overflow: hidden;
  }

  .responsive-table tbody tr.loading-row,
  .responsive-table tbody tr.empty-row {
    display: block;
    padding: 12px 14px;
  }

  .responsive-table tbody tr.loading-row td,
  .responsive-table tbody tr.empty-row td {
    display: block;
    padding: 0;
    border: 0;
  }

  .responsive-table tbody tr.loading-row td::before,
  .responsive-table tbody tr.empty-row td::before {
    display: none;
  }

  .responsive-table tbody td {
    display: grid;
    grid-template-columns: minmax(96px, 38%) minmax(0, 1fr);
    gap: 8px 12px;
    align-items: start;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
  }

  .responsive-table tbody td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    line-height: 1.35;
  }

  .responsive-table tbody td:last-child {
    border-bottom: 0;
  }

  .responsive-table tbody td[colspan] {
    display: block;
    grid-template-columns: 1fr;
  }

  .responsive-table tbody td[colspan]::before {
    display: none;
  }

  .responsive-table .row-actions {
    flex-wrap: wrap;
  }

  .status-pill,
  .alert-badge {
    white-space: normal;
  }
}

@media (max-width: 680px) {
  .topbar {
    padding: 14px;
    gap: 12px;
  }

  .topbar h1 {
    font-size: 18px;
  }

  .topbar .brand-logo-shell {
    width: 100%;
    max-width: 280px;
    padding: 12px 14px;
  }

  .topbar .brand-logo-freedrive {
    max-width: 220px;
  }

  .topbar-actions form,
  .topbar > form {
    width: 100%;
    justify-content: space-between;
  }

  .user-chip {
    flex: 1 1 auto;
    min-width: 0;
  }

  .layout {
    padding: 14px;
  }

  .summary-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .desktop-menu {
    display: none;
  }

  .mobile-menu {
    display: block;
  }

  .menu-link {
    width: 100%;
    justify-content: flex-start;
  }

  .filters,
  .actions,
  .topbar-actions,
  .topbar form {
    width: 100%;
  }

  .filters label,
  .filters button,
  .actions button {
    width: 100%;
  }

  th,
  td {
    padding: 10px;
  }

  .metric strong {
    font-size: 24px;
  }

  .bar-row {
    grid-template-columns: minmax(64px, 72px) minmax(0, 1fr);
  }

  .bar-row strong {
    grid-column: 2;
    text-align: left;
  }

  .report-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .timeline-item {
    grid-template-columns: 1fr;
  }

  .timeline-item b {
    text-align: left;
  }

  .login-panel .brand-logo-freedrive {
    width: min(200px, 100%);
    height: auto;
  }

  .login-brand.brand-block h1 {
    font-size: 20px;
  }

  .login-panel {
    padding: 20px;
  }

  .toast {
    right: 14px;
    left: 14px;
    max-width: none;
  }
}
