:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #d1d5db;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --danger: #b91c1c;
  --success: #166534;
  --warning: #c2410c;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 1rem;
}

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

header h1 {
  margin: 0;
  font-size: 1.25rem;
}

nav {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.card h2 {
  margin-top: 0;
  font-size: 1.1rem;
}

.btn {
  display: inline-block;
  padding: 0.65rem 1rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

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

.btn-primary:hover {
  background: var(--primary-hover);
  text-decoration: none;
}

.btn-secondary {
  background: #e5e7eb;
  color: var(--text);
}

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

.btn + .btn {
  margin-left: 0.5rem;
}

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

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

th,
td {
  text-align: left;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
}

th {
  font-size: 0.875rem;
  color: var(--muted);
}

.form-group {
  margin-bottom: 1rem;
}

label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 600;
}

input,
textarea,
select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
}

textarea {
  min-height: 100px;
  resize: vertical;
}

.actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.alert-error {
  background: #fee2e2;
  color: var(--danger);
  border: 1px solid #fecaca;
}

.alert-success {
  background: #dcfce7;
  color: var(--success);
  border: 1px solid #bbf7d0;
}

.meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.empty {
  color: var(--muted);
  font-style: italic;
}

.qr-panel {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  align-items: flex-start;
}

.qr-image {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}

.qr-meta {
  flex: 1;
  min-width: 220px;
}

.qr-url {
  word-break: break-all;
}

.loan-panel {
  margin-bottom: 1rem;
}

.loan-status-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.loan-badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.loan-badge--active {
  background: #dcfce7;
  color: var(--success);
}

.loan-badge--planned {
  background: #dbeafe;
  color: #1d4ed8;
}

.loan-badge--inactive {
  background: #f3f4f6;
  color: var(--muted);
}

.loan-history {
  margin-top: 1.5rem;
}

.loan-history h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.portal-shell {
  max-width: 520px;
}

.portal-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.portal-header h1 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
}

.portal-plate {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.portal-entry-actions {
  display: grid;
  gap: 0.75rem;
}

.portal-entry-actions .btn {
  width: 100%;
  text-align: center;
}

.portal-entry-hint {
  margin-top: 0.75rem;
}

.portal-context {
  margin-bottom: 1rem;
}

.portal-loan-banner {
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.portal-loan-banner--active {
  background: #dcfce7;
  border: 1px solid #bbf7d0;
  color: var(--success);
}

.portal-loan-banner--planned {
  background: #dbeafe;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
}

.portal-actions {
  display: grid;
  gap: 0.75rem;
}

.portal-actions .btn {
  width: 100%;
  text-align: center;
  padding: 0.9rem 1rem;
}

.portal-loan-section {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.portal-loan-section h2 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}

.portal-loan-panel {
  margin-top: 0.75rem;
}

.portal-loan-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.auth-step {
  max-width: 420px;
  margin: 0 auto;
}

.otp-hint {
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  margin-top: 0.75rem;
}

.report-toolbar--guest {
  max-width: 520px;
  margin: 0 auto 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.report-page {
  --report-page-width: 900px;
}

.report-page__main {
  width: min(100%, var(--report-page-width));
  margin: 0 auto;
  padding: 0 1rem 1.5rem;
}

.report-page__alert:empty {
  display: none;
}

.report-page__alert {
  margin-bottom: 0.75rem;
}

.report-page__main > .card {
  margin-bottom: 0;
}

.report-toolbar {
  display: block;
}

.report-toolbar__inner {
  width: min(100%, var(--report-page-width, 900px));
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.report-toolbar__left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  flex: 1 1 auto;
}

.report-toolbar__titles {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.report-toolbar__title {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.2;
}

.report-toolbar__subtitle {
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.2;
}

.report-toolbar__actions {
  display: flex;
  gap: 0.5rem;
  flex: 0 0 auto;
}

.site-header--minimal nav,
.site-header--portal nav,
.report-page--portal .site-header nav {
  display: none;
}

@media (max-width: 640px) {
  .report-toolbar__inner {
    flex-direction: column;
    align-items: stretch;
  }

  .report-toolbar__left {
    width: 100%;
  }

  .report-toolbar__actions {
    width: 100%;
  }

  .report-toolbar__actions .btn {
    width: 100%;
  }
}

.reporter-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-right: 0.35rem;
}

.reporter-badge--guest {
  background: #fef3c7;
  color: #92400e;
}

.reporter-badge--driver {
  background: #dbeafe;
  color: #1d4ed8;
}

.reporter-badge--admin {
  background: #f3f4f6;
  color: var(--muted);
}

.reporter-panel {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.reporter-panel__header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.radio-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.yes-no {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.form-section-title {
  margin: 1rem 0 0.25rem;
  font-size: 1.05rem;
}

.liability-details {
  margin-top: 0.5rem;
}

.form-stack {
  display: grid;
  gap: 0.75rem;
}

.field-hint {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
  color: var(--muted-text, #666);
}

.meta--warning {
  color: #9a6700;
}

.reporter-panel__subsection {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color, #ddd);
}

.status-legend {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.status-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.status-bullet {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-bullet--red {
  background: var(--danger);
}

.status-bullet--orange {
  background: var(--warning);
}

.status-bullet--green {
  background: var(--success);
}

.status-bullet--gray {
  background: #9ca3af;
}

.due-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.875rem;
}

.due-badge--red { color: var(--danger); }
.due-badge--orange { color: var(--warning); }
.due-badge--green { color: var(--success); }
.due-badge--gray { color: var(--muted); }

.type-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.type-label-text {
  flex-shrink: 0;
}

.type-help {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
}

.type-help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1rem;
  height: 1.1rem;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: #eef2ff;
  color: var(--primary);
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
  cursor: help;
}

.type-help-tooltip {
  display: none;
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.5rem);
  transform: translateX(-50%);
  z-index: 20;
  width: max-content;
  max-width: 16rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.4;
  box-shadow: var(--shadow);
  text-align: left;
  white-space: normal;
}

.type-help:hover .type-help-tooltip,
.type-help:focus-within .type-help-tooltip {
  display: block;
}

.subsection {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.subsection h3 {
  margin: 0 0 1rem;
  font-size: 1rem;
}

.history-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

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

.history-meta {
  color: var(--muted);
  font-size: 0.875rem;
}

.history-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-shrink: 0;
}

.history-intro {
  color: var(--muted);
  font-size: 0.875rem;
  margin: 0 0 1rem;
}

.history-item__header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.history-type-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  flex-shrink: 0;
}

.history-type-badge--wartung {
  background: #e3f2fd;
  color: #1565c0;
}

.history-type-badge--reparatur {
  background: #f3e5f5;
  color: #6a1b9a;
}

.history-type-badge--schaden {
  background: #fff3e0;
  color: #e65100;
}

.history-type-badge--unfall {
  background: #ffebee;
  color: #c62828;
}

.photo-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.photo-gallery__item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-width: 120px;
}

.photo-gallery__item img,
.history-photos img {
  width: 100%;
  max-width: 120px;
  height: 80px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.history-photos {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.history-files {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.maintenance-file-upload {
  display: inline-block;
  margin-top: 0.5rem;
  cursor: pointer;
}

.damage-context {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: #fff8e1;
  border-radius: 4px;
  border: 1px solid #ffe082;
}

.link-button {
  background: none;
  border: none;
  padding: 0;
  color: var(--primary);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
}

.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.calendar-title {
  margin: 0;
  font-size: 1rem;
  text-align: center;
  flex: 1;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.35rem;
}

.calendar-weekday {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  padding: 0.25rem 0;
}

.calendar-day {
  aspect-ratio: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.calendar-day--empty {
  border: none;
  background: transparent;
  cursor: default;
}

.calendar-day--today {
  box-shadow: inset 0 0 0 2px var(--primary);
}

.calendar-day--has-repair {
  background: color-mix(in srgb, var(--primary) 12%, var(--surface));
  font-weight: 600;
}

.calendar-day--selected {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.calendar-day--selected.calendar-day--today {
  box-shadow: inset 0 0 0 2px #fff;
}

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.calendar-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.calendar-legend-dot {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 999px;
  display: inline-block;
}

.calendar-legend-dot--repair {
  background: color-mix(in srgb, var(--primary) 35%, var(--surface));
  border: 1px solid var(--primary);
}

.calendar-legend-dot--today {
  box-shadow: inset 0 0 0 2px var(--primary);
  background: var(--surface);
}

.outlook-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.outlook-weekday {
  background: var(--surface);
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  padding: 0.5rem 0.25rem;
}

.outlook-day {
  min-height: 7.5rem;
  background: var(--surface);
  border: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0.35rem;
  gap: 0.25rem;
}

.outlook-day--empty {
  min-height: 7.5rem;
  background: color-mix(in srgb, var(--surface) 92%, var(--border));
  cursor: default;
}

.outlook-day--today .outlook-day__number {
  background: var(--primary);
  color: #fff;
}

.outlook-day--selected {
  box-shadow: inset 0 0 0 2px var(--primary);
}

.outlook-day__number {
  align-self: flex-start;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.4;
  min-width: 1.4rem;
  text-align: center;
  border-radius: 999px;
  padding: 0 0.25rem;
}

.outlook-day__events {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  overflow: hidden;
}

.outlook-event {
  display: block;
  font-size: 0.68rem;
  line-height: 1.25;
  padding: 0.15rem 0.35rem;
  border-radius: 3px;
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.outlook-event--incident {
  background: #c62828;
}

.outlook-event--repair {
  background: #6a1b9a;
}

.outlook-event--service {
  background: #1565c0;
}

.outlook-event--hu {
  background: #e65100;
}

.outlook-event--au {
  background: #2e7d32;
}

.outlook-day__more {
  font-size: 0.65rem;
  color: var(--muted);
  padding-left: 0.15rem;
}

.calendar-agenda__section {
  margin-bottom: 1.25rem;
}

.calendar-agenda__section h4 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

.calendar-legend-dot--incident {
  background: #c62828;
}

.calendar-legend-dot--service {
  background: #1565c0;
}

.calendar-legend-dot--hu {
  background: #e65100;
}

.calendar-legend-dot--au {
  background: #2e7d32;
}

.due-badge--blue {
  background: color-mix(in srgb, #2563eb 12%, var(--surface));
  color: #1d4ed8;
}

.status-bullet--blue {
  background: #2563eb;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
}

.photo-thumb {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.photo-thumb img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.file-input-large {
  display: block;
  width: 100%;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.damage-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.circumstance-grid {
  display: grid;
  gap: 0.5rem;
}

@media (min-width: 640px) {
  .circumstance-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.circumstance-item {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  font-size: 0.875rem;
}

.sketch-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.incident-sketch-canvas {
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  touch-action: none;
}

.grid-form {
  display: grid;
  gap: 1rem;
}

@media (min-width: 640px) {
  .grid-form {
    grid-template-columns: 1fr 1fr;
  }

  .grid-form .span-2 {
    grid-column: span 2;
  }
}

.status-cell {
  white-space: nowrap;
}

.license-preview {
  margin-top: 1rem;
  max-width: 100%;
}

.license-preview img {
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.grid-2 {
  display: grid;
  gap: 1rem;
}

@media (min-width: 640px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .btn {
    width: 100%;
    margin-left: 0 !important;
  }

  .actions {
    flex-direction: column;
  }
}
