:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #182025;
  --muted: #64727c;
  --line: #dce4e8;
  --green: #1f8a70;
  --green-dark: #146451;
  --orange: #f08a24;
  --red: #d94646;
  --shadow: 0 18px 48px rgba(18, 28, 36, .12);
}

* { box-sizing: border-box; }
[x-cloak] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 24px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.84);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 10;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(28px, 4vw, 42px); line-height: 1; }
h2 { font-size: 22px; }
h3 { font-size: 17px; }
.eyebrow {
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.top-actions, .row-actions, .filters, .detail-tabs, .main-nav { display: flex; align-items: center; gap: 8px; }
.primary, .ghost, .filters button, .detail-tabs button, .event-row button, .doc-row button, .doc-row a, .verify-button, .main-nav button, .small-upload {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 0 14px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.primary {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  font-weight: 750;
}
.primary:hover { background: var(--green-dark); }
.ghost:hover, .filters button.active, .detail-tabs button.active, .main-nav button.active { border-color: var(--green); color: var(--green-dark); background: #edf7f3; }
.main-nav {
  flex: 1;
  justify-content: center;
}
.main-nav button {
  font-weight: 800;
}
.full { width: 100%; }
.shell { padding: 26px clamp(18px, 4vw, 56px) 42px; }
.summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.summary > div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.metric { font-weight: 850; font-size: 26px; }
.summary span:last-child, .card-title p, dt, .detail-head p, .event-row span, .doc-row span, .subtle { color: var(--muted); }
.color-line {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 7px;
}
.color-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 1px solid rgba(24, 32, 37, .22);
  background: #c9d0d4;
  box-shadow: inset 0 1px 2px rgba(255,255,255,.65);
  vertical-align: -1px;
  margin-right: 7px;
}
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 22px;
  align-items: start;
}
.upcoming-view {
  margin-bottom: 24px;
}
.upcoming-list {
  display: grid;
  gap: 9px;
}
.upcoming-row {
  width: 100%;
  min-height: 74px;
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr) minmax(180px, 260px);
  gap: 16px;
  align-items: center;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--ink);
}
.upcoming-row:hover {
  border-color: rgba(31,138,112,.5);
  box-shadow: 0 10px 26px rgba(18, 28, 36, .08);
}
.upcoming-row time {
  color: var(--green-dark);
  font-weight: 850;
}
.upcoming-row div {
  min-width: 0;
  display: grid;
  gap: 3px;
}
.upcoming-row span {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}
.vehicle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.vehicle-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.vehicle-card:hover, .vehicle-card.selected { transform: translateY(-2px); box-shadow: var(--shadow); border-color: rgba(31,138,112,.5); }
.photo-wrap { position: relative; height: 180px; overflow: hidden; background: #d8e0e4; }
.photo-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.type-pill {
  position: absolute;
  left: 12px;
  top: 12px;
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
}
.card-body { padding: 16px; }
.card-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 16px;
}
.card-title strong { white-space: nowrap; }
.card-events { display: grid; gap: 10px; margin: 0; }
.card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}
.small-upload {
  background: #fff;
  font-weight: 800;
}
.small-upload input { display: none; }
.verify-button {
  background: #182025;
  border-color: #182025;
  color: #fff;
  font-weight: 800;
}
.verify-button:hover { background: #2a363d; }
.card-events div, .info-list div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfc;
}
dt { font-size: 12px; font-weight: 800; text-transform: uppercase; margin-bottom: 4px; }
dd { margin: 0; font-weight: 700; }
.soon { border-color: rgba(240,138,36,.65) !important; background: #fff6eb !important; }
.urgent { border-color: rgba(217,70,70,.68) !important; background: #fff0f0 !important; }
.detail {
  position: sticky;
  top: 112px;
  max-height: calc(100vh - 132px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.detail-head, .modal-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
}
.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.detail-tabs { padding: 12px 16px 0; }
.panel { padding: 16px 20px 22px; }
.info-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0 0 16px;
}
.stack, .event-form, .modal { display: grid; gap: 12px; }
label { display: grid; gap: 6px; color: var(--muted); font-weight: 700; font-size: 13px; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
  min-height: 40px;
}
textarea { resize: vertical; }
.event-form {
  grid-template-columns: 1fr 1fr;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}
.event-form textarea, .event-form .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; min-height: 40px; }
.check input { width: auto; min-height: 0; }
.event-list, .doc-list { display: grid; gap: 10px; margin: 10px 0 18px; }
.event-row, .doc-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  background: #fff;
}
.event-row p { margin-top: 4px; color: var(--muted); font-size: 14px; }
.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 14px;
  text-align: center;
}
.upload {
  border: 1px dashed var(--green);
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  color: var(--green-dark);
  background: #edf7f3;
}
.upload input { display: none; }
.photo-upload {
  border: 1px dashed var(--green);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 14px;
  background: #edf7f3;
  color: var(--green-dark);
}
.photo-upload input {
  background: #fff;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(15, 24, 30, .42);
  padding: 20px;
}
.modal {
  width: min(520px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 0 20px 20px;
}
.modal-head { padding-left: 0; padding-right: 0; }
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  max-width: min(420px, calc(100vw - 36px));
  border-radius: 8px;
  background: #182025;
  color: #fff;
  padding: 13px 16px;
  box-shadow: var(--shadow);
  font-weight: 750;
}
@media (max-width: 1040px) {
  .layout { grid-template-columns: 1fr; }
  .detail { position: static; max-height: none; }
}
@media (max-width: 720px) {
  .topbar, .section-head { align-items: stretch; flex-direction: column; }
  .top-actions, .filters, .main-nav, .card-actions { flex-wrap: wrap; justify-content: flex-start; }
  .summary { grid-template-columns: 1fr 1fr; }
  .event-row, .doc-row { align-items: stretch; flex-direction: column; }
  .row-actions { justify-content: space-between; }
  .upcoming-row { grid-template-columns: 1fr; gap: 8px; }
}
@media (max-width: 460px) {
  .summary, .info-list, .event-form { grid-template-columns: 1fr; }
}
