:root {
  --navy: #0b1f3a;
  --gold: #c8a24d;
  --gold-dark: #8a6a1f;
  --bg: #ffffff;
  --soft: #f5f7fa;
  --line: #e3e7ed;
  --muted: #5b6777;
  --red: #b3261e;
  --red-bg: #fdecea;
  --amber: #8a5a00;
  --amber-bg: #fff4d6;
  --green: #1a7f37;
  --green-bg: #e6f4ea;
}

* { box-sizing: border-box; }
/* label and div rules below would otherwise override the browser's own hidden handling */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--navy);
  font-family: Montserrat, system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}
a { color: inherit; }
h1, h2, p { margin: 0; }
code { background: var(--soft); padding: 1px 5px; border-radius: 4px; font-size: 0.92em; }

.shell {
  display: grid;
  grid-template-columns: 230px minmax(0, 620px) 320px;
  justify-content: center;
  min-height: 100vh;
}

/* Left navigation */
.nav {
  position: sticky; top: 0; align-self: start;
  height: 100vh; padding: 14px 14px 20px;
  display: flex; flex-direction: column; gap: 4px;
}
.brand { display: block; padding: 4px 10px 14px; }
.brand img { width: 150px; height: auto; display: block; }
.brand .logo-mark { display: none; }
.nav-link {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 16px; border-radius: 999px;
  text-decoration: none; font-size: 17px; font-weight: 500;
}
.nav-link:hover { background: var(--soft); }
.nav-link.active { font-weight: 700; }
.nav-link.active svg { stroke: var(--gold-dark); stroke-width: 2.2; }
.logout { margin-top: auto; padding: 0 16px; }
.link-btn { background: none; border: 0; padding: 6px 0; color: var(--muted); font: inherit; cursor: pointer; }
.link-btn:hover { color: var(--navy); text-decoration: underline; }

/* Centre column */
.main { border-left: 1px solid var(--line); border-right: 1px solid var(--line); min-height: 100vh; }
.main-head {
  position: sticky; top: 0; z-index: 5;
  background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.main-head h1 { font-size: 20px; font-weight: 700; padding: 14px 18px; }
.back { text-decoration: none; margin-right: 8px; }
.tabs { display: flex; }
.tab {
  flex: 1; text-align: center; padding: 12px 6px 11px;
  text-decoration: none; color: var(--muted); font-weight: 600;
  border-bottom: 3px solid transparent;
}
.tab:hover { background: var(--soft); }
.tab.active { color: var(--navy); border-bottom-color: var(--gold); }
.count {
  margin-left: 7px; font-size: 12px; font-weight: 700;
  background: var(--soft); border-radius: 999px; padding: 2px 8px; color: var(--navy);
}
.mini-stats { display: none; gap: 14px; flex-wrap: wrap; padding: 10px 18px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 13px; }

.flash { margin: 12px 18px 0; padding: 10px 14px; border-radius: 10px; background: var(--green-bg); color: var(--green); font-weight: 600; }
.flash-error { background: var(--red-bg); color: var(--red); }
.notice { margin: 14px 18px 0; padding: 12px 14px; border-radius: 10px; background: var(--amber-bg); color: var(--amber); }

/* Composer */
.composer { border-bottom: 1px solid var(--line); padding: 12px 18px; }
.composer summary { display: flex; align-items: center; gap: 12px; cursor: pointer; list-style: none; }
.composer summary::-webkit-details-marker { display: none; }
.composer-prompt { color: var(--muted); font-size: 17px; }
.composer[open] .composer-prompt { color: var(--navy); font-weight: 600; }
.composer form { margin-top: 14px; }

/* Posts */
.post { display: flex; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.post:hover { background: #fafbfc; }
.avatar {
  flex: none; width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700; letter-spacing: 0.03em;
  background: var(--soft); color: var(--navy);
}
.avatar-overdue { background: var(--red); color: #fff; }
.avatar-urgent { background: var(--red-bg); color: var(--red); }
.avatar-soon { background: var(--amber-bg); color: var(--amber); }
.avatar-ok { background: var(--green-bg); color: var(--green); }
.avatar-missing { border: 2px dashed #b9c1cc; background: #fff; color: var(--muted); }
.avatar-add { background: var(--navy); color: var(--gold); font-size: 24px; font-weight: 500; }
.post-body { flex: 1; min-width: 0; }
.post-head { display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: baseline; }
.reg { font-weight: 700; text-decoration: none; letter-spacing: 0.02em; }
.reg:hover { text-decoration: underline; }
.post-text { font-size: 16px; font-weight: 600; margin: 2px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.warn { color: var(--amber); font-weight: 600; }
.status-overdue, .status-urgent { color: var(--red); }
.status-soon { color: var(--amber); }
.status-ok { color: var(--green); }
.empty { padding: 48px 18px; text-align: center; color: var(--muted); }

.renew { margin-top: 8px; }
.renew summary { cursor: pointer; color: var(--gold-dark); font-weight: 600; font-size: 14px; width: fit-content; }
.renew summary:hover { text-decoration: underline; }
.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-top: 10px; }
.inline-form label { flex: 1 1 180px; }

/* Forms */
label { display: block; font-size: 13px; font-weight: 600; }
input, select {
  display: block; width: 100%; margin-top: 5px;
  padding: 10px 12px; font: inherit; font-weight: 400; color: var(--navy);
  border: 1px solid #c3cad4; border-radius: 8px; background: #fff;
}
input:focus, select:focus, .btn:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 2px;
}
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid .wide { grid-column: 1 / -1; }
.hint { display: block; margin-top: 5px; font-weight: 400; color: var(--muted); }
.check { display: flex; gap: 10px; align-items: center; font-weight: 500; font-size: 14px; }
.check input { width: 18px; height: 18px; margin: 0; flex: none; }
.interval { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; align-items: start; grid-column: 1 / -1; padding: 12px; background: var(--soft); border-radius: 10px; }
.interval .hint { grid-column: 1 / -1; margin: 0; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; vertical-align: 2px; }
.tag-phv { background: var(--soft); color: var(--muted); }
.tag-psv { background: var(--navy); color: var(--gold); }
.form-actions { display: flex; justify-content: flex-end; margin-top: 14px; }
.btn {
  display: inline-block; padding: 9px 18px; border-radius: 999px;
  border: 1px solid #c3cad4; background: #fff; color: var(--navy);
  font: inherit; font-weight: 600; font-size: 14px; text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--soft); }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover { background: #142d52; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #8f1d17; }
.pad { padding: 18px; }
.section-top { border-top: 1px solid var(--line); }
.section-top h2 { font-size: 17px; margin-bottom: 4px; }
.section-top form { margin: 12px 0; }
.danger { border-top: 1px solid var(--line); }
.danger summary { cursor: pointer; color: var(--red); font-weight: 600; }
.danger p { margin: 10px 0; }

/* Vehicles */
.vehicle { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.vehicle-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.vehicle-head .reg { font-size: 17px; margin-right: 8px; }
.docs { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 12px 0 4px; }
.doc { display: flex; flex-direction: column; font-weight: 600; font-size: 14px; }
.doc-label { font-size: 12px; font-weight: 500; color: var(--muted); }

/* Right column */
.aside { padding: 14px 0 20px 24px; position: sticky; top: 0; align-self: start; display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--soft); border-radius: 16px; padding: 16px; }
.card h2 { font-size: 18px; font-weight: 700; margin-bottom: 12px; }
.card p { margin-bottom: 8px; overflow-wrap: anywhere; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0; }
.stat { background: #fff; border-radius: 12px; padding: 10px 12px; border-left: 4px solid var(--navy); }
.stat dt { font-size: 12px; color: var(--muted); font-weight: 500; }
.stat dd { margin: 0; font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-overdue { border-left-color: var(--red); }
.stat-urgent { border-left-color: #e0786f; }
.stat-soon { border-left-color: var(--gold); }
.text-link { color: var(--gold-dark); font-weight: 600; text-decoration: none; }
.text-link:hover { text-decoration: underline; }

/* Login */
.login-body { background: var(--soft); display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login { background: #fff; width: 100%; max-width: 380px; padding: 28px; border-radius: 16px; border-top: 4px solid var(--gold); display: flex; flex-direction: column; gap: 16px; box-shadow: 0 8px 30px rgba(11, 31, 58, 0.08); }
.login img { width: 200px; margin: 0 auto; }
.login h1 { font-size: 18px; text-align: center; }
.login .flash { margin: 0; }

@media (max-width: 1100px) {
  .shell { grid-template-columns: 76px minmax(0, 620px); }
  .aside { display: none; }
  .mini-stats { display: flex; }
  .nav { padding: 14px 8px; align-items: center; }
  .nav-link span, .logout { display: none; }
  .nav-link { padding: 13px; }
  .brand { padding: 4px 0 12px; }
  .brand .logo-full { display: none; }
  .brand .logo-mark { display: block; width: 40px; }
}

@media (max-width: 640px) {
  .shell { display: block; padding-bottom: 64px; }
  .main { border: 0; }
  .nav {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; z-index: 10;
    height: auto; flex-direction: row; justify-content: space-around;
    padding: 6px 8px; background: #fff; border-top: 1px solid var(--line);
  }
  .brand { display: none; }
  .nav-link { flex-direction: column; gap: 2px; padding: 6px 14px; font-size: 11px; border-radius: 12px; }
  .nav-link span { display: block; }
  .grid { grid-template-columns: 1fr; }
  .docs { grid-template-columns: 1fr 1fr; }
  .main-head h1, .post, .composer, .vehicle, .pad, .mini-stats { padding-left: 16px; padding-right: 16px; }
  .flash, .notice { margin-left: 16px; margin-right: 16px; }
}

/* Inspection history */
.history { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 12px; }
.history th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 10px 6px 0; border-bottom: 1px solid var(--line); }
.history td { padding: 10px 10px 10px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.history tr:last-child td { border-bottom: 0; }
.danger-link { color: var(--red); font-size: 13px; font-weight: 600; }
.danger-link:hover { color: #8f1d17; }
.avatar-round { border-radius: 50%; font-size: 11px; }
@media (max-width: 640px) {
  .history th:nth-child(4), .history td:nth-child(4) { display: none; }
}

/* Hire block on the vehicle form */
.hire { grid-column: 1 / -1; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px 16px; margin: 0; }
.hire legend { font-size: 13px; font-weight: 700; padding: 0 6px; }
.hire .check { margin-bottom: 12px; }
.hire .grid { gap: 12px; }
