/* Fleet Admin Portal ------------------------------------------------------ */

:root {
  --ink: #10192a;
  --ink-2: #3d4a60;
  --muted: #6b7a90;
  --line: #e2e7ee;
  --line-strong: #cbd4e1;
  --bg: #f4f6fa;
  --panel: #ffffff;
  --brand: #075c82;
  --brand-2: #0094d4;
  --brand-soft: #e3f6fc;

  --ok: #147d5a;
  --ok-soft: #e3f4ec;
  --warn: #97600b;
  --warn-soft: #fdf1dc;
  --info: #1f5fa8;
  --info-soft: #e6effb;
  --danger: #b3261e;
  --danger-soft: #fdeceb;
  --neutral: #55607a;
  --neutral-soft: #eef1f6;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 25, 42, .06), 0 8px 24px rgba(16, 25, 42, .06);
  --shadow-lg: 0 12px 40px rgba(16, 25, 42, .18);
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --control-height: 40px;
}

* { box-sizing: border-box; }

/* display rules below would otherwise beat the hidden attribute */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.28rem; }
h2 { font-size: 1.02rem; }
h3 { font-size: .92rem; }
p { margin: 0; }
a { color: var(--brand-2); }

.muted { color: var(--muted); }
.small { font-size: .8rem; }
.tiny { font-size: .72rem; }
.strong { font-weight: 650; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* Login ------------------------------------------------------------------ */

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(160deg, #12b4e8 0%, #0094d4 45%, #075c82 100%);
}

.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border-radius: 16px;
  padding: 32px;
  box-shadow: var(--shadow-lg);
  display: grid;
  gap: 14px;
}

.login-brand { display: flex; }
.login-card h1 { font-size: 1.4rem; }
.login-card .muted { margin-bottom: 4px; }

.brand-mark {
  display: block;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
  flex: none;
}

/* Shell ------------------------------------------------------------------ */

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

.sidebar {
  width: 244px;
  flex: none;
  background: var(--brand-2);
  color: #dbe6f5;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px;
}
.sidebar-head strong { display: block; color: #fff; font-size: .95rem; }
.sidebar-head .muted { color: #93a9c6; }

.nav { flex: 1; overflow-y: auto; padding: 6px 10px 20px; display: grid; gap: 2px; align-content: start; }

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: #c6d5e9;
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
}
.nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav a.active { background: #fff; color: var(--brand-2); font-weight: 650; }
.nav a .nav-icon { width: 20px; display: inline-flex; justify-content: center; font-size: .95rem; }
.nav a .badge { margin-left: auto; }

.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, .12);
}
.sidebar-user { flex: 1; min-width: 0; }
.sidebar-user strong { display: block; color: #fff; font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot .muted { color: #93a9c6; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(255, 255, 255, .16);
  color: #fff; display: grid; place-items: center;
  font-size: .78rem; font-weight: 650; flex: none;
}

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

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 16px 24px;
  background: rgba(244, 246, 250, .92);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.menu-btn { display: none; }

.content { padding: 20px 24px 64px; display: grid; gap: 18px; align-content: start; }

/* Cards and layout ------------------------------------------------------- */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.card-head h2 { flex: 1; }
.card-body { padding: 16px; display: grid; gap: 12px; }
.card-body.flush { padding: 0; }

.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: grid; gap: 10px; }

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 2px;
}
.stat .value { font-size: 1.7rem; font-weight: 680; letter-spacing: -.02em; line-height: 1.1; }
.stat .label { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.stat.accent { border-left: 3px solid var(--brand-2); }
.stat.danger .value { color: var(--danger); }
.stat.ok .value { color: var(--ok); }

/* Buttons ---------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ink);
  font: inherit; font-size: .85rem; font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s ease, border-color .12s ease, transform .06s ease;
}
.btn:hover { background: #f7f9fc; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, #12b4e8, var(--brand-2) 55%, var(--brand)); border-color: var(--brand-2); color: #fff; }
.btn-primary:hover { background: linear-gradient(135deg, var(--brand-2), var(--brand)); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #97201a; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--neutral-soft); }
.btn-sm { padding: 5px 10px; font-size: .78rem; }
.btn-block { width: 100%; }

.icon-btn {
  border: none; background: transparent; cursor: pointer;
  color: inherit; font-size: 1.1rem; padding: 6px 8px; border-radius: 8px;
}
.icon-btn:hover { background: rgba(255, 255, 255, .12); }
.topbar .icon-btn:hover { background: var(--neutral-soft); }

/* Forms ------------------------------------------------------------------ */

.field { display: grid; gap: 6px; font-size: .82rem; font-weight: 600; color: var(--ink-2); min-width: 0; }
.field > span { font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field input, .field select, .field textarea {
  font: inherit; font-size: .88rem; font-weight: 500; line-height: 1.3;
  min-height: var(--control-height);
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px var(--brand-soft);
}
.field select {
  appearance: none; -webkit-appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%236b7a90' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='5 8 10 13 15 8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
}
.field textarea { min-height: 78px; padding: 10px 13px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 9px; font-size: .85rem; font-weight: 500; }
.check input { width: 16px; height: 16px; min-height: 0; }

.form-error {
  background: var(--danger-soft); color: var(--danger);
  border-radius: var(--radius-sm); padding: 9px 11px; font-size: .82rem; font-weight: 600;
}

.filters {
  display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end;
  padding: 14px 16px; border-bottom: 1px solid var(--line); background: #fbfcfe;
}
.filters .field { flex: 1 1 200px; min-width: 180px; max-width: 320px; }

.search-field { position: relative; }
.search-field .fa-magnifying-glass {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: .82rem; pointer-events: none;
}
.search-field input { padding-left: 34px; }

/* Tables ----------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
thead th {
  text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 700;
  padding: 10px 14px; background: #fbfcfe; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: #f7f9fc; }
td .cell-title { font-weight: 620; }
td .cell-sub { color: var(--muted); font-size: .78rem; }

/* Badges ----------------------------------------------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: .72rem; font-weight: 700; letter-spacing: .01em;
  background: var(--neutral-soft); color: var(--neutral);
  white-space: nowrap;
}
.badge i { font-size: .78rem; line-height: 1; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-brand { background: var(--brand-soft); color: var(--brand); }

/* Parking map ------------------------------------------------------------ */

.parking-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.parking-group {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); overflow: hidden;
}
.parking-group header {
  padding: 10px 13px; background: #fbfcfe; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px;
}
.parking-group header strong { font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.parking-group ul { list-style: none; margin: 0; padding: 8px; display: grid; gap: 6px; }
.parking-group li {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 9px; border-radius: var(--radius-sm); background: #f7f9fc;
  font-size: .82rem; font-weight: 600;
}
.parking-group li > span:first-child { flex: none; }
.parking-group li > span.muted.tiny { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.parking-group li > span.badge { flex: none; }
.parking-group.status-in_use header { background: var(--info-soft); }
.parking-group.status-maintenance header { background: var(--warn-soft); }
.parking-group.status-return_overdue header { background: var(--danger-soft); }

/* Schedule --------------------------------------------------------------- */

.schedule { overflow-x: auto; }
.schedule-grid { min-width: 720px; display: grid; }
.schedule-row { display: grid; grid-template-columns: 150px repeat(var(--days, 7), minmax(96px, 1fr)); }
.schedule-row.head > div { background: #fbfcfe; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.schedule-row > div { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 8px; min-height: 58px; }
.schedule-row > div:first-child { position: sticky; left: 0; background: var(--panel); z-index: 2; font-size: .8rem; font-weight: 650; }
.schedule-row.head > div:first-child { background: #fbfcfe; }
.schedule-chip {
  display: block; width: 100%; text-align: left;
  border: none; border-left: 3px solid var(--brand-2);
  background: var(--brand-soft); color: var(--brand);
  border-radius: 6px; padding: 4px 6px; margin-bottom: 4px; cursor: pointer;
  font: inherit; font-size: .7rem; font-weight: 650; line-height: 1.25;
}
.schedule-chip small { display: block; font-weight: 500; opacity: .85; }
.schedule-chip.status-in_progress { background: var(--info-soft); border-color: var(--info); color: var(--info); }
.schedule-chip.status-completed { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.schedule-chip.status-cancelled { background: var(--neutral-soft); border-color: var(--neutral); color: var(--neutral); text-decoration: line-through; }
.schedule-chip.status-return_overdue { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }

/* Charts ----------------------------------------------------------------- */

/* One shared grid so every row's label column sizes to the longest label
   and all bar tracks line up, instead of each row sizing independently. */
.bars { display: grid; grid-template-columns: minmax(0, max-content) 1fr auto; gap: 9px 10px; align-items: center; font-size: .8rem; }
.bar-row { display: contents; }
.bar-row .label { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.bar-track { background: var(--neutral-soft); border-radius: 999px; height: 9px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--brand-2); border-radius: 999px; }
.bar-row .value { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Feedback --------------------------------------------------------------- */

.empty { display: grid; gap: 8px; justify-items: center; text-align: center; padding: 34px 16px; color: var(--muted); }
.empty .glyph { font-size: 1.7rem; }
.empty strong { color: var(--ink); font-size: .92rem; }

.skeleton { display: grid; gap: 8px; padding: 16px; }
.skeleton div { height: 13px; border-radius: 6px; background: linear-gradient(90deg, #eef1f6 25%, #f7f9fc 50%, #eef1f6 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
.skeleton div:nth-child(2) { width: 80%; }
.skeleton div:nth-child(3) { width: 60%; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.toast-stack { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 100; }
.toast {
  background: var(--ink); color: #fff; padding: 11px 15px;
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  font-size: .85rem; font-weight: 600; max-width: 340px;
  animation: rise .18s ease-out;
}
.toast.ok { background: #126b4f; }
.toast.error { background: var(--danger); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.modal-root { position: fixed; inset: 0; background: rgba(16, 25, 42, .48); display: grid; place-items: center; padding: 20px; z-index: 90; }
.modal {
  width: min(560px, 100%); max-height: 88vh; overflow: auto;
  background: var(--panel); border-radius: 14px; box-shadow: var(--shadow-lg);
  animation: rise .16s ease-out;
}
.modal.wide { width: min(820px, 100%); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.modal-head h2 { flex: 1; }
.modal-body { padding: 20px; display: grid; gap: 14px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; background: #fbfcfe; }

.scrim { position: fixed; inset: 0; background: rgba(16, 25, 42, .4); z-index: 25; }

.detail-list { display: grid; gap: 0; }
.detail-list div { display: flex; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: .85rem; }
.detail-list div:last-child { border-bottom: none; }
.detail-list dt { color: var(--muted); min-width: 140px; font-weight: 600; }
.detail-list dd { margin: 0; font-weight: 550; }

.tabs { display: flex; gap: 4px; background: var(--neutral-soft); padding: 3px; border-radius: 10px; }
.tabs button {
  border: none; background: transparent; font: inherit; font-size: .82rem; font-weight: 650;
  padding: 6px 13px; border-radius: 8px; cursor: pointer; color: var(--muted);
}
.tabs button.active { background: #fff; color: var(--ink); box-shadow: var(--shadow); }

.pill-list { display: flex; flex-wrap: wrap; gap: 6px; }

/* Responsive ------------------------------------------------------------- */

@media (max-width: 900px) {
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 30;
    transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .content { padding: 16px 14px 60px; }
  .topbar { padding: 12px 14px; }
  .grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .stat .value { font-size: 1.4rem; }
  .field-row { grid-template-columns: 1fr; }
}

@media (min-width: 901px) { .scrim { display: none; } }

@media print {
  .sidebar, .topbar-actions, .filters { display: none; }
  .content { padding: 0; }
  .card { box-shadow: none; }
}
