@import url('https://fonts.googleapis.com/css2?family=Oswald:wght@400;500;600;700&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@600&display=swap');

:root {
  --ink: #1C2333;
  --ink-2: #262F45;
  --paper: #EDEFF0;
  --paper-2: #FBFBFA;
  --line: #D7DADC;
  --amber: #E8A23D;
  --amber-bg: #E8A23D1c;
  --red: #C1432B;
  --red-bg: #C1432B15;
  --green: #3E7D5A;
  --green-bg: #3E7D5A15;
  --slate: #6B7280;
  --plate: #F4C430;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: 'IBM Plex Sans', sans-serif;
}

#app { min-height: 100%; }

/* ---------- Login screen background ---------- */

.auth-shell {
  background: #1a1a2e url('/img/login-background.png') no-repeat center center;
  background-size: cover;
}

button, input, select {
  font-family: inherit;
  font-size: 14.5px;
}

button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}

.icon { width: 17px; height: 17px; flex-shrink: 0; }

/* ---------- Auth screens ---------- */

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--paper-2);
  border: 1.5px solid var(--line);
  border-radius: 8px;
  padding: 32px 30px;
  box-shadow: 0 1px 2px rgba(28,35,51,.04), 0 12px 32px rgba(28,35,51,.07);
}

.auth-company-logo {
  display: block;
  width: 100%;
  max-width: 220px;
  margin: 0 auto 20px;
  border-radius: 8px;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}

.logo-mark {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--amber);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  flex-shrink: 0;
}

.auth-logo span {
  font-family: 'Oswald', sans-serif;
  font-weight: 600;
  font-size: 22px;
  letter-spacing: 0.01em;
}

.auth-card h1 {
  font-family: 'Oswald', sans-serif;
  font-weight: 500;
  font-size: 19px;
  margin: 0 0 4px;
}

.auth-card p.sub {
  color: var(--slate);
  font-size: 13.5px;
  margin: 0 0 22px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}

.field label {
  font-size: 12.5px;
  color: var(--slate);
  font-weight: 500;
}

.field input, .field select, .field textarea {
  padding: 9px 11px;
  border: 1.5px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
}

.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--ink);
}

.field textarea {
  resize: vertical;
  min-height: 60px;
  font-family: inherit;
}

.btn-primary {
  width: 100%;
  background: var(--ink);
  color: var(--paper-2);
  border: none;
  border-radius: 5px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
  transition: background 0.12s ease;
}

.btn-primary:hover { background: var(--ink-2); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }

.btn-link {
  background: none;
  border: none;
  color: var(--ink);
  text-decoration: underline;
  cursor: pointer;
  font-size: 13.5px;
  padding: 0;
}

.auth-switch {
  margin-top: 18px;
  font-size: 13.5px;
  color: var(--slate);
  text-align: center;
}

.error-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--red-bg);
  color: var(--red);
  padding: 9px 12px;
  border-radius: 5px;
  font-size: 13.5px;
  margin-bottom: 14px;
}

/* ---------- App shell ---------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--ink);
  color: var(--paper-2);
  display: flex;
  flex-direction: column;
  padding: 22px 18px;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 30px;
}

.sidebar-logo span {
  font-family: 'Oswald', sans-serif;
  font-weight: 600;
  font-size: 18px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 5px;
  color: #C7CCD6;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 2px;
  background: none;
  border: none;
  border-left: 3px solid transparent;
  width: 100%;
  text-align: left;
  transition: color 0.12s ease;
}

.nav-item.active { border-left-color: var(--amber); color: #fff; padding-left: 7px; }
.nav-item:hover:not(.active) { color: #fff; }

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid #333D53;
  padding-top: 14px;
}

.sidebar-user {
  font-size: 13px;
  color: #C7CCD6;
  margin-bottom: 8px;
  word-break: break-word;
}

.logout-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  background: none;
  border: none;
  color: #C7CCD6;
  cursor: pointer;
  font-size: 13px;
  padding: 4px 0;
}

.logout-btn:hover { color: #fff; }

.main { flex: 1; min-width: 0; }

.topline {
  padding: 30px 34px 22px;
}

.topline h1 {
  font-family: 'Oswald', sans-serif;
  font-weight: 500;
  font-size: 27px;
  margin: 0 0 4px;
  letter-spacing: 0.01em;
}

.topline p {
  color: var(--slate);
  font-size: 14px;
  margin: 0;
}

.stat-strip {
  display: flex;
  flex-wrap: wrap;
  padding: 16px 34px;
  border-top: 1.5px solid var(--line);
  border-bottom: 1.5px solid var(--line);
  background: var(--paper-2);
}

.stat-tile {
  padding: 0 26px;
  border-right: 1px solid var(--line);
  position: relative;
}
.stat-tile:first-child { padding-left: 0; }
.stat-tile:last-child { border-right: none; }

.stat-tile-clickable {
  background: none;
  border: none;
  border-right: 1px solid var(--line);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  border-radius: 6px;
  transition: background 0.12s ease;
}
.stat-tile-clickable:hover { background: #1C233308; }
.stat-tile-clickable.stat-tile-active {
  background: #1C233312;
  box-shadow: inset 0 -3px 0 var(--ink);
}

.stat-tile .num {
  font-family: 'Oswald', sans-serif;
  font-weight: 600;
  font-size: 32px;
  line-height: 1;
  display: block;
  font-variant-numeric: tabular-nums;
}

.stat-tile .label {
  font-size: 12.5px;
  color: var(--slate);
  margin-top: 4px;
  display: block;
}

.content { padding: 26px 34px 60px; max-width: 1180px; }

/* ---------- Vehicles ---------- */

.add-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: none;
  border: 1.5px dashed #B0AEA5;
  border-radius: 6px;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
  margin-bottom: 20px;
}

.add-form {
  background: var(--paper-2);
  border: 1.5px solid var(--line);
  border-radius: 6px;
  padding: 18px;
  margin-bottom: 20px;
  box-shadow: 0 1px 2px rgba(28,35,51,.03), 0 8px 20px rgba(28,35,51,.05);
}

/* ---------- Toolbar: search + sort ---------- */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 180px;
  max-width: 320px;
  padding: 8px 12px;
  border: 1.5px solid var(--line);
  border-radius: 5px;
  background: var(--paper-2);
  color: var(--ink);
}

.sort-toggle {
  display: flex;
  border: 1.5px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
  flex-shrink: 0;
}

.sort-toggle button {
  background: var(--paper-2);
  border: none;
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 500;
  color: var(--slate);
  cursor: pointer;
}

.sort-toggle button + button { border-left: 1.5px solid var(--line); }
.sort-toggle button.active { background: var(--ink); color: var(--paper-2); }

/* ---------- Toasts ---------- */

.toast-stack {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 50;
}

.toast {
  background: var(--ink);
  color: var(--paper-2);
  padding: 11px 16px;
  border-radius: 6px;
  font-size: 13.5px;
  box-shadow: 0 8px 24px rgba(28,35,51,.25);
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 320px;
  animation: toast-in 0.18s ease;
}

.toast.error { background: var(--red); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.add-form-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.add-form-head h3 {
  font-family: 'Oswald', sans-serif;
  font-weight: 500;
  font-size: 17px;
  margin: 0;
}

.close-x {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--slate);
  padding: 4px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.vehicle-table-head {
  display: grid;
  grid-template-columns: 90px 1fr 85px 92px 82px 105px 150px 75px 20px;
  gap: 10px;
  padding: 0 4px 8px;
  border-bottom: 2px solid var(--ink);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--slate);
}

.vehicle-row-btn {
  width: 100%;
  display: grid;
  grid-template-columns: 90px 1fr 85px 92px 82px 105px 150px 75px 20px;
  align-items: center;
  gap: 10px;
  padding: 14px 4px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  text-align: left;
  transition: background 0.1s ease;
}

.vehicle-row-btn:hover { background: #1C233308; }

.reg-plate {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  font-size: 14.5px;
  letter-spacing: 0.03em;
  background: var(--plate);
  color: var(--ink);
  padding: 4px 9px;
  border-radius: 3px;
  border: 1.5px solid var(--ink);
  text-align: center;
  min-width: 88px;
  display: inline-block;
}

.make-model { font-size: 14.5px; font-weight: 500; }
.make-model.empty { color: #B0AEA5; }

.chip {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: 4px;
  display: inline-block;
  white-space: nowrap;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

.defect-count { font-size: 13px; font-weight: 600; }

.chevron { transition: transform 0.15s; color: var(--slate); }
.chevron.open { transform: rotate(180deg); }

.expand-panel {
  padding: 6px 4px 24px;
  border-bottom: 1px solid var(--line);
  animation: expand-in 0.15s ease;
}

@keyframes expand-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.expand-panel h4 {
  font-family: 'Oswald', sans-serif;
  font-weight: 500;
  font-size: 15px;
  margin: 0;
}

.identity-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.expand-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.remove-link {
  background: none;
  border: none;
  color: var(--red);
  font-size: 12.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
}

.defect-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.defect-row.resolved { opacity: 0.5; }

.sev-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

.defect-desc { flex: 1; font-size: 14px; }
.defect-desc.resolved { text-decoration: line-through; }

.defect-date { font-size: 12px; color: var(--slate); }

.icon-btn {
  background: none;
  border: 1.5px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
  padding: 3px 6px;
  display: flex;
  align-items: center;
}

.icon-btn.plain { border: none; padding: 3px; }

.defect-form { display: flex; gap: 8px; margin-top: 10px; }
.defect-form input { flex: 1; }

.empty-note {
  color: var(--slate);
  font-size: 14px;
  padding: 40px 4px;
  border-top: 1px solid var(--line);
  text-align: center;
}

.empty-note svg {
  width: 34px;
  height: 34px;
  color: #B0AEA5;
  margin-bottom: 10px;
}

@media (max-width: 720px) {
  .sidebar { width: 72px; padding: 18px 10px; }
  .sidebar-logo span, .nav-item span, .sidebar-user, .logout-btn span { display: none; }
  .nav-item, .logout-btn { justify-content: center; }
  .grid-2 { grid-template-columns: 1fr; }
  .vehicle-table-head, .vehicle-row-btn { grid-template-columns: 90px 1fr 60px 20px; }
  .vehicle-table-head > *:nth-child(4), .vehicle-table-head > *:nth-child(5), .vehicle-table-head > *:nth-child(6), .vehicle-table-head > *:nth-child(7), .vehicle-table-head > *:nth-child(8),
  .vehicle-row-btn > *:nth-child(4), .vehicle-row-btn > *:nth-child(5), .vehicle-row-btn > *:nth-child(6), .vehicle-row-btn > *:nth-child(7), .vehicle-row-btn > *:nth-child(8) { display: none; }
}

/* ---------- Printable service sheet ---------- */

.print-sheet {
  background: #fff;
  color: #1a1a1a;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 32px 36px;
  max-width: 720px;
  font-family: 'IBM Plex Sans', sans-serif;
}

.ps-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 2px solid #1a1a1a;
  padding-bottom: 14px;
  margin-bottom: 4px;
}

.ps-header h1 {
  font-family: 'Oswald', sans-serif;
  font-weight: 600;
  font-size: 22px;
  margin: 0;
}

.ps-header p {
  font-size: 12.5px;
  color: #555;
  margin: 2px 0 0;
}

.ps-reg {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 700;
  font-size: 18px;
  background: var(--plate);
  color: #1a1a1a;
  padding: 5px 12px;
  border-radius: 3px;
  border: 1.5px solid #1a1a1a;
}

.ps-vehicle-name {
  font-size: 14px;
  color: #555;
  margin: 6px 0 20px;
}

.print-sheet h2 {
  font-family: 'Oswald', sans-serif;
  font-weight: 500;
  font-size: 15px;
  margin: 22px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid #ccc;
}

.ps-table, .ps-tyre-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.ps-table td {
  padding: 5px 0;
  border-bottom: 1px solid #eee;
}

.ps-table .ps-label {
  color: #555;
  width: 45%;
}

.ps-table .ps-value {
  font-weight: 500;
}

.ps-tyre-table th, .ps-tyre-table td {
  border: 1px solid #ddd;
  padding: 6px 10px;
  text-align: center;
}

.ps-tyre-table .ps-label {
  text-align: left;
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  background: #f7f7f5;
}

.ps-empty, .ps-note {
  font-size: 13px;
  color: #777;
  margin: 4px 0;
}

.ps-notes {
  font-size: 13.5px;
  white-space: pre-wrap;
}

.ps-signoff {
  display: flex;
  gap: 24px;
  margin-top: 40px;
  padding-top: 20px;
}

.ps-signoff-line {
  flex: 1;
  border-top: 1px solid #1a1a1a;
  padding-top: 4px;
}

.ps-signoff-line span {
  font-size: 11px;
  color: #777;
}

.ps-checkbox-line {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  margin: 10px 0 14px;
}

.ps-checkbox {
  width: 15px;
  height: 15px;
  border: 1.5px solid #1a1a1a;
  border-radius: 2px;
  flex-shrink: 0;
  display: inline-block;
}

.ps-work-lines {
  margin-bottom: 16px;
}

.ps-work-line {
  border-bottom: 1px solid #ccc;
  height: 26px;
}

.ps-mini-signoff {
  display: flex;
  gap: 24px;
  margin-bottom: 6px;
}

.ps-mini-signoff > div {
  flex: 1;
  border-top: 1px solid #1a1a1a;
  padding-top: 4px;
}

.ps-mini-signoff span {
  font-size: 11px;
  color: #777;
}

.ps-inline-blank {
  display: inline-block;
  border-bottom: 1px solid #1a1a1a;
  min-width: 70px;
  height: 1.1em;
  margin: 0 4px;
}

.ps-inline-blank-wide {
  min-width: 220px;
}

.ps-input {
  border: none;
  border-bottom: 1px solid #1a1a1a;
  font: inherit;
  font-size: 13.5px;
  padding: 1px 4px;
  background: transparent;
  min-width: 70px;
  color: #1a1a1a;
}

.ps-input:focus {
  outline: none;
  background: #f5f5f0;
}

.ps-input-wide {
  min-width: 220px;
  width: 100%;
  max-width: 320px;
}

.ps-work-line-input {
  border: none;
  border-bottom: 1px solid #ccc;
  width: 100%;
  height: 26px;
  font: inherit;
  font-size: 13.5px;
  background: transparent;
  color: #1a1a1a;
}

.ps-work-line-input:focus {
  outline: none;
  background: #f5f5f0;
}

.ps-checkbox-input {
  width: 16px;
  height: 16px;
  accent-color: #1a1a1a;
  flex-shrink: 0;
}

.ps-textarea {
  width: 100%;
  border: 1px solid #ccc;
  border-radius: 4px;
  font: inherit;
  font-size: 13.5px;
  padding: 8px;
  min-height: 60px;
  resize: vertical;
  color: #1a1a1a;
  background: #fff;
}

.ps-sheet-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.ps-sheet-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  width: 100%;
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
  cursor: pointer;
  text-align: left;
}

@media print {
  body * { visibility: hidden; }
  .print-sheet, .print-sheet * { visibility: visible; }
  .print-sheet {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    border: none;
    padding: 0;
  }
  .print-sheet input, .print-sheet textarea {
    background: transparent !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .print-sheet textarea {
    border: 1px solid #ccc !important;
  }
}
