:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #dde4ee;
  --line-strong: #c7d2df;
  --text: #16202e;
  --muted: #64748b;
  --accent: #176b87;
  --accent-dark: #0f526a;
  --ok: #127a55;
  --ok-bg: #e7f7ef;
  --done: #475569;
  --done-bg: #eef2f7;
  --danger: #b42318;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.14);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, "Helvetica Neue", sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

:focus-visible {
  outline: 3px solid rgba(23, 107, 135, 0.34);
  outline-offset: 2px;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar__inner,
.page {
  width: min(1440px, calc(100% - 48px));
  margin: 0 auto;
}

.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 86px;
  padding: 18px 0;
}

.topbar__eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 13px;
}

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

h1 {
  margin-bottom: 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0;
}

.topbar__date {
  color: var(--muted);
  font-size: 14px;
  text-align: right;
  white-space: nowrap;
}

.page {
  padding: 28px 0 44px;
}

.summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.metric {
  min-height: 132px;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric__label {
  display: block;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 14px;
}

.metric__value {
  display: block;
  font-size: 42px;
  line-height: 1;
  letter-spacing: 0;
}

.metric__value--time {
  font-size: 30px;
  line-height: 1.15;
}

.filters {
  display: grid;
  grid-template-columns: 190px minmax(240px, 1fr) auto auto;
  align-items: end;
  gap: 14px;
  margin-bottom: 20px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.field {
  min-width: 0;
}

.field label,
.segmented legend {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
}

.field input {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
}

.field input:hover,
.field input:focus {
  border-color: var(--accent);
}

.segmented {
  display: flex;
  align-items: end;
  gap: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.segmented legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.segmented label {
  position: relative;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 0 16px;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--line-strong);
}

.segmented label:first-of-type span {
  border-radius: 6px 0 0 6px;
}

.segmented label:last-of-type span {
  border-left: 0;
  border-radius: 0 6px 6px 0;
}

.segmented input:checked + span {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
}

.segmented input:focus-visible + span {
  outline: 3px solid rgba(23, 107, 135, 0.34);
  outline-offset: 2px;
  z-index: 1;
}

.button {
  min-height: 42px;
  padding: 0 15px;
  color: var(--surface);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  font-weight: 600;
}

.button:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.button--ghost {
  color: var(--accent);
  background: var(--surface);
}

.button--ghost:hover {
  color: var(--surface);
}

.journal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.journal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}

.journal__header h2 {
  margin-bottom: 3px;
  font-size: 20px;
}

.journal__header p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
}

.table-wrap {
  overflow-x: auto;
}

.vehicle-table {
  width: 100%;
  border-collapse: collapse;
}

.vehicle-table th,
.vehicle-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.vehicle-table th {
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.vehicle-row {
  transition: background-color 0.15s ease;
}

.vehicle-row:hover,
.vehicle-row:focus {
  background: #f1f7fa;
}

.vehicle-row:last-child td {
  border-bottom: 0;
}

.plate {
  display: inline-flex;
  align-items: center;
  min-width: 128px;
  padding: 7px 10px;
  color: #111827;
  background: #ffffff;
  border: 2px solid #111827;
  border-radius: 5px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0;
  white-space: nowrap;
  box-shadow: inset 0 -10px 0 rgba(15, 23, 42, 0.04);
}

.datetime {
  display: block;
  min-width: 150px;
  color: var(--text);
  font-size: 14px;
}

.duration {
  font-weight: 700;
  white-space: nowrap;
}

.thumb-button {
  width: 106px;
  height: 66px;
  padding: 0;
  overflow: hidden;
  background: #eef2f7;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
}

.thumb-button:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 107, 135, 0.12);
}

.thumb-button img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-missing {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 106px;
  height: 66px;
  color: var(--muted);
  background: #f1f5f9;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.badge--inside {
  color: var(--ok);
  background: var(--ok-bg);
}

.badge--done {
  color: var(--done);
  background: var(--done-bg);
}

.empty-state {
  padding: 48px 24px 54px;
  text-align: center;
  border-top: 1px solid var(--line);
}

.empty-state h3 {
  margin-bottom: 8px;
  font-size: 20px;
}

.empty-state p {
  margin-bottom: 0;
  color: var(--muted);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal.is-open {
  display: flex;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.58);
}

.modal__panel {
  position: relative;
  z-index: 1;
  width: min(100%, 980px);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.modal__close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  color: var(--text);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 50%;
  font-size: 28px;
  line-height: 1;
}

.modal__close:hover {
  color: var(--danger);
}

.details {
  padding: 26px;
}

.details__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding-right: 44px;
  margin-bottom: 22px;
}

.details__title {
  margin: 0 0 12px;
}

.details__status-note {
  margin: 10px 0 0;
  color: var(--ok);
  font-weight: 700;
}

.details__grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.details__item {
  padding: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.details__item span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 13px;
}

.details__item strong {
  display: block;
  font-size: 15px;
}

.details__photos {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.details__photo {
  min-width: 0;
}

.details__photo h3 {
  margin-bottom: 10px;
  font-size: 16px;
}

.details__photo button {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
}

.details__photo .photo-missing {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
}

.modal__panel--image {
  width: min(100%, 920px);
  padding: 18px;
  background: #111827;
}

.modal__panel--image img {
  width: 100%;
  max-height: calc(100vh - 150px);
  object-fit: contain;
  background: #0f172a;
  border-radius: 6px;
}

.modal__panel--image p {
  margin: 12px 44px 0 0;
  color: #e5e7eb;
  font-size: 14px;
}

body.modal-open {
  overflow: hidden;
}

@media (max-width: 1040px) {
  .summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filters {
    grid-template-columns: 1fr 1fr;
  }

  .button--ghost {
    justify-self: start;
  }

  .details__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .topbar__inner,
  .page {
    width: min(100% - 28px, 1440px);
  }

  .topbar__inner {
    display: block;
    min-height: 0;
  }

  h1 {
    font-size: 23px;
  }

  .topbar__date {
    margin-top: 8px;
    text-align: left;
    white-space: normal;
  }

  .page {
    padding-top: 18px;
  }

  .summary,
  .filters,
  .details__grid,
  .details__photos {
    grid-template-columns: 1fr;
  }

  .metric {
    min-height: 108px;
    padding: 18px;
  }

  .metric__value {
    font-size: 36px;
  }

  .metric__value--time {
    font-size: 26px;
  }

  .filters {
    padding: 14px;
  }

  .segmented {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .segmented span {
    justify-content: center;
    padding: 0 10px;
    text-align: center;
  }

  .journal__header {
    padding: 17px 16px;
  }

  .table-wrap {
    overflow: visible;
  }

  .vehicle-table,
  .vehicle-table thead,
  .vehicle-table tbody,
  .vehicle-table tr,
  .vehicle-table td {
    display: block;
  }

  .vehicle-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .vehicle-table tbody {
    padding: 12px;
    background: var(--bg);
  }

  .vehicle-row {
    margin-bottom: 12px;
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
  }

  .vehicle-row:last-child {
    margin-bottom: 0;
  }

  .vehicle-table td {
    display: grid;
    grid-template-columns: 118px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
  }

  .vehicle-table td:last-child {
    border-bottom: 0;
  }

  .vehicle-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
  }

  .plate {
    min-width: 0;
    width: fit-content;
    max-width: 100%;
    font-size: 17px;
  }

  .thumb-button,
  .photo-missing {
    width: 130px;
    max-width: 100%;
    height: 76px;
  }

  .modal {
    padding: 12px;
  }

  .modal__panel {
    max-height: calc(100vh - 24px);
  }

  .details {
    padding: 18px;
  }

  .details__head {
    display: block;
    padding-right: 42px;
  }
}

@media (max-width: 420px) {
  .vehicle-table td {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .thumb-button,
  .photo-missing {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
  }
}

.photo-set {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
  min-width: 220px;
}

.photo-tile {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.photo-tile__label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}

.details__photo-group {
  min-width: 0;
}

.details__photo-group h3 {
  margin-bottom: 10px;
  font-size: 16px;
}

.details__photo-group .photo-set {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-width: 0;
}

.details__photo-group .thumb-button,
.details__photo-group .photo-missing {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
}

.photo-note {
  margin: -3px 0 10px;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 720px) {
  .photo-set {
    min-width: 0;
  }

  .details__photo-group .photo-set {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  .photo-tile {
    width: 100%;
  }
}
