/* ==========================================================
   Fleet Management — Admin UI
   ========================================================== */
:root {
  --bg: #f6f7f9;
  --sidebar: #1a1f2e;
  --sidebar-ink: #e5e7eb;
  --sidebar-muted: #9ca3af;
  --brand: #0f4c5c;
  --brand-dark: #0a3842;
  --accent: #e76f51;
  --ink: #1f2937;
  --muted: #64748b;
  --card: #ffffff;
  --border: #e2e8f0;
  --ok: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --urgent: #dc2626;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.75rem; margin: 0 0 .25em; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 0 0 .75em; font-weight: 700; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { border-bottom: 1px solid rgba(255,255,255,.07); }
}

.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-ink);
  display: flex; flex-direction: column;
  padding: 1.25rem 1rem;
}
.sidebar .brand {
  display: flex; align-items: center; gap: .6rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 1.1rem;
}
.sidebar .brand img { height: 36px; width: auto; border-radius: 4px; background: #fff; padding: 2px; object-fit: contain; }
.sidebar .brand-mark {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: var(--brand); border-radius: 4px;
  font-size: .82rem;
  font-weight: 800;
  letter-spacing: .05em;
}
.sidebar .brand-text { font-weight: 700; font-size: .95rem; line-height: 1.2; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  color: var(--sidebar-ink);
  padding: .6rem .75rem;
  border-radius: 4px;
  font-size: .92rem;
  display: block;
}
.nav-item:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.nav-group {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
  padding: 1rem .75rem .35rem;
}

.sidebar-foot { padding-top: 1rem; border-top: 1px solid rgba(255,255,255,.08); }
.user-chip { margin-bottom: .6rem; }
.user-name { color: #fff; font-weight: 600; font-size: .9rem; }
.user-role { color: var(--sidebar-muted); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }

.btn-ghost {
  background: transparent;
  border: 1px solid rgba(255,255,255,.18);
  color: var(--sidebar-ink);
  padding: .4rem .75rem;
  border-radius: 4px;
  font-size: .82rem;
  display: inline-block;
  text-decoration: none;
}
.btn-ghost:hover { background: rgba(255,255,255,.05); text-decoration: none; }

.main {
  padding: 2rem 2.25rem;
  max-width: 1200px;
  width: 100%;
}
@media (max-width: 640px) { .main { padding: 1.25rem; } }

/* ---------- Page head ---------- */
.page-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap;
}
.page-head p.muted { margin: 0; color: var(--muted); font-size: .9rem; }
.back-link { font-size: .85rem; color: var(--muted); display: inline-block; margin-bottom: .25rem; }
.back-link:hover { color: var(--brand); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--ink);
  padding: .55rem 1rem;
  border-radius: 4px;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
}
.btn:hover { text-decoration: none; background: #f3f4f6; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-block { display: block; width: 100%; justify-content: center; }

/* ---------- Cards / panels ---------- */
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.panel.p-0 { padding: 0; overflow: hidden; }
.panel-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 1rem;
}
.panel-head h2 { margin: 0; }
.panel-muted { background: #fafbfc; border-style: dashed; }

/* ---------- Stats ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.25rem;
  border-left: 3px solid var(--brand);
}
.stat-card-muted { border-left-color: var(--border); }
.stat-card-alert { border-left-color: var(--danger); background: #fef2f2; }
.stat-label { color: var(--muted); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; font-weight: 700; margin-bottom: .35rem; }
.stat-value { font-size: 2.1rem; font-weight: 700; line-height: 1; }
.stat-sub { font-size: .78rem; color: var(--muted); margin-top: .4rem; font-style: italic; }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
.table th {
  background: #fafbfc;
  font-size: .72rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: #fafbfc; }
.row-inactive { opacity: .55; }
.row-actions { white-space: nowrap; }

/* ---------- UK Registration plate ---------- */
.reg-plate {
  display: inline-block;
  background: #fbdc11;
  color: #000;
  padding: .22rem .6rem;
  border-radius: 3px;
  font-family: "Charles Wright", "UKNumberPlate", Arial, sans-serif;
  font-weight: 800;
  letter-spacing: .05em;
  font-size: .85rem;
  border: 1px solid #d9b800;
  text-decoration: none;
  text-transform: uppercase;
}
a:hover .reg-plate { text-decoration: none; }
.reg-plate.large { font-size: 1.5rem; padding: .4rem 1rem; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  background: #e2e8f0;
  color: #334155;
  padding: .18rem .55rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: capitalize;
  white-space: nowrap;
}
.badge-ok       { background: #d1fae5; color: #065f46; }
.badge-due-soon { background: #fef3c7; color: #92400e; }
.badge-urgent   { background: #fee2e2; color: #991b1b; }
.badge-expired  { background: var(--urgent); color: #fff; }
.badge-unknown  { background: #e5e7eb; color: var(--muted); }

.role-admin    { background: #e0e7ff; color: #3730a3; }
.role-mechanic { background: #fef3c7; color: #92400e; }
.role-driver   { background: #d1fae5; color: #065f46; }

.status-available        { background: #d1fae5; color: #065f46; }
.status-in_use           { background: #dbeafe; color: #1e40af; }
.status-in_maintenance   { background: #fef3c7; color: #92400e; }
.status-out_of_service   { background: #fee2e2; color: #991b1b; }

/* ---------- Forms ---------- */
.form { max-width: 960px; }
.form-section { margin-bottom: 2rem; }
.form-section h2 {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  font-weight: 700;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
}
.form-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 1rem; }
.col-3  { grid-column: span 3; }
.col-4  { grid-column: span 4; }
.col-6  { grid-column: span 6; }
.col-12 { grid-column: span 12; }
@media (max-width: 700px) { .col-3, .col-4, .col-6 { grid-column: span 12; } }

label { display: block; font-size: .85rem; font-weight: 600; color: var(--ink); }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=search], input[type=url], input[type=tel],
select, textarea {
  display: block; width: 100%; margin-top: .3rem;
  padding: .55rem .7rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  font: inherit;
  color: var(--ink);
  font-weight: 400;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--brand);
  outline-offset: -1px;
}
textarea { resize: vertical; min-height: 3rem; }

small.err { display: block; color: var(--danger); font-size: .78rem; margin-top: .25rem; font-weight: 500; }
.checkbox { display: flex !important; align-items: center; gap: .5rem; font-weight: 500 !important; cursor: pointer; }
.checkbox input { width: auto !important; margin: 0 !important; }

.form-actions {
  display: flex; gap: .5rem; justify-content: flex-end; align-items: center;
  padding-top: 1rem; border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.form-actions .btn-danger { margin-right: auto; }

/* ---------- Filter bar ---------- */
.filter-bar {
  display: flex; gap: .75rem; margin-bottom: 1rem;
  align-items: center; flex-wrap: wrap;
}
.filter-bar input[type=search] { max-width: 360px; margin: 0; }

/* ---------- Definition list ---------- */
.dl { display: grid; grid-template-columns: 160px 1fr; gap: .6rem 1rem; margin: 0; }
.dl dt { color: var(--muted); font-size: .82rem; font-weight: 500; }
.dl dd { margin: 0; font-weight: 500; }

/* ---------- Flash ---------- */
.flash {
  padding: .75rem 1rem;
  border-radius: 4px;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  background: #fff;
  font-size: .9rem;
}
.flash-info    { border-color: #bae6fd; background: #f0f9ff; color: #075985; }
.flash-error   { border-color: #fecaca; background: #fef2f2; color: #991b1b; }
.flash-success { border-color: #bbf7d0; background: #f0fdf4; color: #14532d; }

/* ---------- Auth pages ---------- */
.auth-body {
  min-height: 100vh;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #eff6ff 0%, #e0e7ff 100%);
  padding: 1rem;
}
.auth-card {
  background: #fff; padding: 2.25rem; border-radius: 10px;
  box-shadow: 0 20px 40px rgba(15,76,92,.1);
  width: 100%; max-width: 400px;
}
.auth-logo { max-height: 56px; margin-bottom: 1rem; }
.auth-brand { color: var(--muted); font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 1rem; font-weight: 600; }
.auth-card h1 { margin-bottom: 1.25rem; }
.auth-card label { display: block; margin-bottom: 1rem; font-size: .85rem; font-weight: 600; }
.auth-card .btn { margin-top: .5rem; }

/* ---------- Misc ---------- */
.muted { color: var(--muted); }
.link { color: var(--brand); font-size: .88rem; text-decoration: none; }
.link:hover { text-decoration: underline; }
.empty-state { color: var(--muted); padding: 2rem 0; text-align: center; font-size: .95rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin-bottom: 1.25rem; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- KPI cards (fines + reports) ----------------------------- */
.kpi-row { display: grid; gap: .75rem; }
.kpi {
    background: #f6f8fc; border: 1px solid #e2e6ee; border-radius: .55rem;
    padding: .8rem .95rem;
}
.kpi-strong { background: #eef3ff; border-color: #c8d6f4; }
.kpi-label  { font-size: .72rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 600; }
.kpi-value  { font-size: 1.45rem; font-weight: 700; color: var(--brand); margin: .25rem 0 .15rem; }
.kpi-sub    { margin: 0; }
