:root {
  --bg: #0f1115;
  --card: #1a1d23;
  --card-inset: #12151b;
  --ink: #e6e9ee;
  --muted: #8b94a1;
  --line: #2a2f37;
  --accent: #4c8dff;
  --accent-ink: #0b0d10;

  --ok-bg: #12231a;
  --ok-ink: #4ade80;
  --warn-bg: #2a2113;
  --warn-ink: #fbbf24;
  --overdue-bg: #2a1416;
  --overdue-ink: #f87171;

  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 1px 3px rgba(0,0,0,.4);
  max-width: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .5rem; }
h2 { font-size: 1.15rem; margin: 0 0 .5rem; }
h1, h2, h3 { line-height: 1.2; font-weight: 600; }
.muted { color: var(--muted); font-size: .9rem; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1.25rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; color: var(--ink); }
.brand:hover { text-decoration: none; color: var(--accent); }
.nav { display: flex; gap: .5rem; align-items: center; }

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

.page-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
}
.page-actions { display: flex; gap: .5rem; align-items: center; }

/* cards */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 1rem;
}
.bike-card { display: block; color: inherit; }
.bike-card:hover { border-color: var(--accent); text-decoration: none; }
.bike-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .5rem; }
.bike-name { font-size: 1.05rem; font-weight: 600; }

.empty { text-align: center; padding: 2rem 1rem; }
.empty .btn { margin-top: 1rem; }

/* callouts */
.callout { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; display: flex; flex-wrap: wrap; gap: .25rem .75rem; align-items: center; }
.callout-warn { background: var(--warn-bg); color: var(--warn-ink); border: 1px solid #5a4718; }
.callout-danger { background: var(--overdue-bg); color: var(--overdue-ink); border: 1px solid #5a2528; }
.callout a { color: inherit; font-weight: 600; }
.inline-item { display: inline-flex; gap: .4rem; align-items: center; }

/* service card */
.due-top { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; margin-bottom: .75rem; }
.due-title { margin: 0; }
.due-summary { margin: .15rem 0 0; color: var(--muted); font-size: .95rem; }
.due-meta { display: grid; grid-template-columns: minmax(7rem, max-content) 1fr; gap: 0; margin: 0; }
.due-meta > * { padding: .4rem 0; border-bottom: 1px solid var(--line); }
.due-meta > :nth-last-child(-n+2) { border-bottom: none; }
.due-meta dt { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
.due-meta dd { margin: 0; font-weight: 600; }

.due-card.badge-ok { border-left: 4px solid var(--ok-ink); }
.due-card.badge-due-soon { border-left: 4px solid var(--warn-ink); }
.due-card.badge-overdue { border-left: 4px solid var(--overdue-ink); }
.due-card.badge-muted { border-left: 4px solid var(--muted); }

/* renewals (MOT / insurance) */
.renewals { display: grid; gap: .5rem; margin-top: .85rem; padding-top: .85rem; border-top: 1px solid var(--line); }
.renewal { display: flex; align-items: center; gap: .6rem; }
.renewal-label { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; min-width: 4.5rem; }
.renewal .badge { margin-left: 0; }

/* badges */
.badge {
  display: inline-flex; align-items: center;
  padding: .15rem .55rem; border-radius: 999px;
  font-size: .8rem; font-weight: 600; white-space: nowrap;
}
.badge-ok { background: var(--ok-bg); color: var(--ok-ink); }
.badge-due-soon { background: var(--warn-bg); color: var(--warn-ink); }
.badge-overdue { background: var(--overdue-bg); color: var(--overdue-ink); }
.badge-muted { background: var(--card-inset); color: var(--muted); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .5rem .9rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font: inherit; font-weight: 500; cursor: pointer;
}
.btn:hover { background: var(--card-inset); text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #3f7fe6; }
.btn-danger { border-color: #5a2528; color: var(--overdue-ink); background: var(--card); }
.btn-danger:hover { background: var(--overdue-bg); }
.btn-link { background: none; border: none; padding: .1rem; }
.btn-block { width: 100%; }
.btn-busy { display: none; }
.btn.htmx-request .btn-busy { display: inline; }
.btn.htmx-request .btn-label { display: none; }

/* forms */
form label { display: flex; flex-direction: column; gap: .3rem; margin: 0.65rem 0; }
form label > span { font-weight: 500; font-size: .9rem; }
input, select, textarea {
  font: inherit; color: inherit;
  padding: .5rem .6rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--card-inset);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent);
}
.form-row { display: grid; gap: .75rem; }
@media (min-width: 560px) { .form-row { grid-template-columns: 1fr 1fr; } }
.form-actions { margin-top: 1rem; display: flex; align-items: center; gap: .75rem; }
.add-note { margin: 0; font-size: .8rem; color: var(--muted); max-width: 320px; }

/* events table */
.events-table { width: 100%; border-collapse: collapse; }
.events-table th, .events-table td { text-align: left; padding: .5rem .4rem; vertical-align: top; }
.events-table th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; border-bottom: 1px solid var(--line); }
.events-table tr + tr td { border-top: 1px solid var(--line); }
.noted { color: var(--muted); }
.events-table td.notes { max-width: 220px; overflow-wrap: anywhere; }
.row-actions { text-align: right; }
.row-actions form { display: inline; }

.tag { display: inline-block; padding: .1rem .5rem; border-radius: 10px; font-size: .8rem; font-weight: 500; }
.tag-service { background: #16263f; color: #7fb0ff; }
.tag-fuel    { background: #14291d; color: #7fcfa0; }
.tag-tyre    { background: #332713; color: #e0b06a; }
.tag-chain   { background: #241a3a; color: #b39ddb; }
.tag-brake   { background: #331a1a; color: #f0908c; }
.tag-repair  { background: #14291d; color: #7fcfa0; }
.tag-mot     { background: #14263a; color: #6fb3ff; }
.tag-insurance { background: #2a2313; color: #e6c36b; }
.tag-other   { background: #1c2129; color: #9aa5b1; }

/* alert */
.alert { padding: .6rem .8rem; border-radius: 8px; margin: .75rem 0; }
.alert-error { background: var(--overdue-bg); color: var(--overdue-ink); }

/* danger zone */
.danger-zone { margin-top: 1rem; padding: 1rem; border: 1px dashed var(--line); border-radius: var(--radius); }

/* auth */
body.auth { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
.auth-card { max-width: 380px; width: 100%; padding: 2rem 1.5rem; margin: 0 auto; }

/* toast */
.toast {
  position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%);
  background: #2a2f37; color: var(--ink); padding: .5rem .9rem; border-radius: 8px;
  font-size: .9rem; animation: fade-in .2s ease; z-index: 20;
}
@keyframes fade-in { from { opacity: 0; transform: translate(-50%, .5rem);} to { opacity: 1; transform: translate(-50%, 0);} }

.busy { display: none; }

/* busy indicator (htmx sets .htmx-request on the [hx-indicator] target) */
.spinner { display: none; width: 1em; height: 1em; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.htmx-request ~ .spinner, .htmx-request .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
