:root {
  color-scheme: light;
  --bg: #f5f6f1;
  --surface: #ffffff;
  --surface-soft: #f0f5f3;
  --ink: #18201f;
  --muted: #68736f;
  --line: #dfe6e2;
  --teal: #0f766e;
  --teal-strong: #0b5f59;
  --blue: #2563eb;
  --amber: #d97706;
  --red: #dc2626;
  --green: #16a34a;
  --shadow: 0 18px 45px rgba(24, 32, 31, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.10), transparent 34rem),
    linear-gradient(315deg, rgba(217, 119, 6, 0.10), transparent 28rem),
    var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.file-action {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.app-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 10px clamp(10px, 2vw, 24px) 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 8px 0 10px;
}

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

.brand-mark {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(15, 118, 110, 0.18);
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--teal);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.55rem, 2vw, 2.35rem);
  line-height: 1.06;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
}

.top-actions,
.toolbar,
.panel-actions,
.dialog-actions,
.dialog-actions > div {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.summary-card {
  min-height: 68px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.summary-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--teal);
}

.summary-card strong {
  display: block;
  margin-top: 7px;
  font-size: clamp(1.25rem, 2vw, 1.85rem);
  line-height: 1;
}

.summary-label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 750;
}

.accent-amber::before {
  background: var(--amber);
}

.accent-red::before {
  background: var(--red);
}

.accent-blue::before {
  background: var(--blue);
}

.toolbar {
  justify-content: space-between;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.search-box {
  display: flex;
  align-items: center;
  min-width: min(310px, 100%);
  flex: 1 1 260px;
  gap: 8px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.segmented {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 4px;
  gap: 3px;
  overflow-x: auto;
}

.segment {
  min-height: 30px;
  border: 0;
  border-radius: 6px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
}

.segment.active {
  background: var(--surface);
  color: var(--teal-strong);
  box-shadow: 0 6px 16px rgba(24, 32, 31, 0.09);
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.danger-btn,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  min-height: 36px;
  border: 1px solid transparent;
  font-weight: 850;
  text-decoration: none;
}

.primary-btn {
  padding: 0 16px;
  background: var(--teal);
  color: #ffffff;
}

.primary-btn:hover {
  background: var(--teal-strong);
}

.secondary-btn,
.ghost-btn {
  padding: 0 14px;
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.ghost-btn {
  background: rgba(255, 255, 255, 0.72);
}

.danger-btn {
  padding: 0 14px;
  background: #fff5f5;
  border-color: #fecaca;
  color: #b91c1c;
}

.icon-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  background: var(--surface);
  border-color: var(--line);
  color: var(--muted);
}

.icon-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover {
  border-color: rgba(15, 118, 110, 0.45);
  color: var(--teal-strong);
}

[data-icon] {
  display: inline-flex;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

[data-icon] svg {
  width: 100%;
  height: 100%;
  stroke-width: 2.2;
}

.workspace {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 10px;
  margin-top: 10px;
  align-items: start;
}

.side-panel {
  display: grid;
  gap: 8px;
  position: sticky;
  top: 12px;
}

.panel-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  padding: 10px;
  box-shadow: var(--shadow);
}

.panel-block h2 {
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.reminder-stack {
  display: grid;
  gap: 6px;
}

.reminder-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 32px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.reminder-chip strong {
  font-size: 0.8rem;
}

.reminder-chip span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 750;
}

.panel-actions {
  align-items: stretch;
  flex-direction: column;
}

.panel-actions .secondary-btn {
  justify-content: flex-start;
}

.file-action {
  cursor: pointer;
}

.file-action input {
  display: none;
}

.source-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}

.source-grid a {
  display: block;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
}

.source-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: left top;
  display: block;
}

.vehicle-list {
  display: grid;
  gap: 7px;
}

.vehicle-card {
  display: grid;
  grid-template-columns: minmax(176px, 0.72fr) minmax(0, 2.8fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.vehicle-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-right: 1px solid var(--line);
  border-bottom: 0;
}

.plate-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.plate {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 32px;
  padding: 3px 8px;
  border-radius: 7px;
  background: #eef2ff;
  border-left: 7px solid #2563eb;
  color: #111827;
  font-size: 1rem;
  font-weight: 950;
  overflow-wrap: anywhere;
}

.category {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: #ecfdf5;
  color: #047857;
  font-size: 0.68rem;
  font-weight: 850;
}

.vehicle-note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.25;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}

.vehicle-actions {
  display: flex;
  gap: 6px;
}

.doc-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.doc-row {
  min-height: 72px;
  padding: 8px 9px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}

.doc-row:last-child {
  border-right: 0;
}

.doc-row::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: var(--green);
}

.doc-row.warning::before {
  background: var(--amber);
}

.doc-row.critical::before,
.doc-row.missing::before {
  background: var(--red);
}

.doc-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.doc-name {
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 900;
  text-transform: uppercase;
}

.doc-date {
  display: block;
  margin-top: 2px;
  font-size: 0.84rem;
  font-weight: 900;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  max-width: 88px;
  padding: 0 7px;
  border-radius: 999px;
  background: #eaf8ef;
  color: #166534;
  font-size: 0.65rem;
  font-weight: 900;
  text-align: center;
}

.status-pill.warning {
  background: #fff7ed;
  color: #9a3412;
}

.status-pill.critical,
.status-pill.missing {
  background: #fef2f2;
  color: #b91c1c;
}

.doc-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.25;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}

.doc-meta a {
  color: var(--teal-strong);
  font-weight: 850;
  text-decoration: none;
}

.doc-meta a:hover {
  text-decoration: underline;
}

.timeline {
  height: 5px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
  margin-top: auto;
}

.timeline span {
  display: block;
  height: 100%;
  width: var(--progress, 0%);
  background: var(--teal);
}

.warning .timeline span {
  background: var(--amber);
}

.critical .timeline span,
.missing .timeline span {
  background: var(--red);
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 10px;
  min-height: 280px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--muted);
}

.empty-state [data-icon] {
  width: 36px;
  height: 36px;
}

.vehicle-dialog {
  width: min(760px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 26px 90px rgba(24, 32, 31, 0.24);
}

.vehicle-dialog::backdrop {
  background: rgba(24, 32, 31, 0.42);
}

.vehicle-dialog form {
  padding: 18px;
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}

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

.form-grid label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 850;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 44px;
  padding: 9px 11px;
  color: var(--ink);
  background: var(--surface);
  outline: 0;
}

.form-grid textarea {
  resize: vertical;
}

.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
  border-color: rgba(15, 118, 110, 0.65);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

.full-width {
  grid-column: 1 / -1;
}

.dialog-actions {
  justify-content: space-between;
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

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

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

  .vehicle-list {
    order: 1;
  }

  .side-panel {
    order: 2;
    position: static;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 840px) {
  .topbar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .toolbar .primary-btn {
    width: 100%;
  }

  .top-actions > *,
  .toolbar .primary-btn {
    flex: 1;
  }

  .segmented {
    width: 100%;
  }

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

  .doc-row {
    min-height: 68px;
    border-right: 1px solid var(--line);
    border-bottom: 0;
  }

  .doc-row:last-child {
    border-right: 0;
  }

  .side-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding-inline: 10px;
  }

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

  .summary-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .summary-card {
    min-height: 64px;
    padding: 10px;
  }

  .summary-card strong {
    font-size: 1.18rem;
  }

  .vehicle-card {
    grid-template-columns: 1fr;
  }

  .vehicle-head {
    grid-template-columns: minmax(0, 1fr) auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .vehicle-actions {
    justify-content: flex-end;
  }

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

  .dialog-actions,
  .dialog-actions > div {
    align-items: stretch;
    flex-direction: column;
  }
}
