/* ==========================================================================
   dashboard.css — Fleet Dashboard design system
   Stripe / Linear / Vercel-inspired premium SaaS look.
   Pure CSS — no build step, drop-in replacement.
   ========================================================================== */

:root{
  /* Brand */
  --brand: #0f6b5c;
  --brand-dark: #0b5347;
  --brand-light: #e6f3f0;
  --brand-ring: rgba(15,107,92,.16);

  /* Neutrals */
  --text: #0f172a;
  --text-mid: #64748b;
  --text-faint: #94a3b8;
  --border: #e7eaef;
  --border-strong: #e2e8f0;
  --bg: #f5f6f8;
  --surface: #ffffff;

  /* Status */
  --green: #16a34a;    --green-bg: #e8f8ee;
  --orange: #d97706;   --orange-bg: #fef3e2;
  --red: #dc2626;      --red-bg: #fdecec;
  --blue: #2563eb;     --blue-bg: #eaf1ff;

  /* Shape / elevation */
  --radius: 10px;
  --radius-sm: 8px;
  --radius-lg: 14px;
  --shadow: 0 2px 8px rgba(15,23,42,.06);
  --shadow-md: 0 8px 24px rgba(15,23,42,.10);

  /* Spacing scale */
  --sp-1: 8px;
  --sp-2: 16px;
  --sp-3: 24px;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

*{ box-sizing: border-box; }

html{ -webkit-text-size-adjust: 100%; }

body{
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3{ margin: 0; letter-spacing: -0.01em; }
h1{ font-size: 18px; font-weight: 700; }
h2{ font-size: 16px; font-weight: 700; }
p{ margin: 0; }

a{ color: var(--brand); }

::selection{ background: var(--brand-light); color: var(--brand-dark); }

/* ── Top nav ─────────────────────────────────────────────────────────── */

.topnav{
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
}

.topnav-inner{
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}

.brand{
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark{
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex: none;
}

.brand-name{
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub{
  font-size: 12px;
  color: var(--text-mid);
  font-weight: 500;
}

/* ── Layout ──────────────────────────────────────────────────────────── */

.wrap{
  max-width: 1180px;
  margin: 0 auto;
  padding: var(--sp-3) var(--sp-3) 60px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  animation: fadeIn .35s ease both;
}

.card-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.card-head h2{ display: flex; align-items: center; gap: 8px; }

.card-sub{ color: var(--text-mid); font-size: 12.5px; margin-top: 2px; }

/* ── KPI cards ───────────────────────────────────────────────────────── */

.kpi-grid{
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--sp-2);
}

.kpi{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  animation: fadeIn .35s ease both;
}

.kpi-label{
  font-size: 12px;
  font-weight: 600;
  color: var(--text-mid);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.kpi-value{
  font-size: 24px;
  font-weight: 700;
  margin-top: 8px;
  color: var(--text);
}

.kpi-value.accent{ color: var(--brand); }

.kpi-skeleton{
  height: 24px;
  width: 60%;
  margin-top: 8px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--border) 25%, #f1f3f6 37%, var(--border) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}

/* ── Forms ───────────────────────────────────────────────────────────── */

.field{
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label, .label{
  font-size: 12px;
  font-weight: 600;
  color: var(--text-mid);
}

.form-grid{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--sp-2);
  align-items: end;
}

input, select, textarea{
  font-family: var(--font);
  font-size: 13.5px;
  color: var(--text);
  padding: 10px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
  width: 100%;
}

input::placeholder{ color: var(--text-faint); }

input:focus, select:focus, textarea:focus{
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}

/* ── Buttons ─────────────────────────────────────────────────────────── */

button, .btn{
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .1s ease, box-shadow .15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

button{
  background: var(--brand);
  color: #fff;
}
button:hover{ background: var(--brand-dark); }
button:active{ transform: translateY(1px); }
button:focus-visible{ box-shadow: 0 0 0 3px var(--brand-ring); }
button:disabled{ opacity: .55; cursor: not-allowed; }

.btn-secondary{
  background: var(--surface) !important;
  color: var(--text) !important;
  border: 1px solid var(--border-strong) !important;
}
.btn-secondary:hover{ background: var(--bg) !important; }

.btn-danger{
  background: var(--red-bg) !important;
  color: var(--red) !important;
  border: 1px solid #f6d3d3 !important;
}
.btn-danger:hover{ background: #fbdcdc !important; }

.btn-ghost{
  background: transparent !important;
  color: var(--brand) !important;
  border: 1px solid transparent !important;
  padding: 6px 8px !important;
}
.btn-ghost:hover{ background: var(--brand-light) !important; }

.btn-sm{ padding: 6px 10px; font-size: 12px; }

.btn-block{ width: 100%; justify-content: center; }

.logout-btn{
  background: var(--surface);
  color: var(--text-mid);
  border: 1px solid var(--border-strong);
  font-weight: 600;
}
.logout-btn:hover{ background: var(--bg); color: var(--text); }

/* ── Tables ──────────────────────────────────────────────────────────── */

.table-scroll{ overflow-x: auto; }

table{
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 640px;
}

thead th{
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-mid);
  background: #fafbfc;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

thead th:last-child, tbody td:last-child{ text-align: right; }

tbody td{
  padding: 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

tbody tr{ transition: background .12s ease; }
tbody tr:hover{ background: #fafbfc; }
tbody tr:last-child td{ border-bottom: none; }

.row-actions{
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.empty-state{
  text-align: center;
  padding: 36px 16px;
  color: var(--text-faint);
  font-size: 13px;
}

/* ── Badges ──────────────────────────────────────────────────────────── */

.badge{
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px 3px 7px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge::before{
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.badge-green{ background: var(--green-bg); color: var(--green); }
.badge-orange{ background: var(--orange-bg); color: var(--orange); }
.badge-red{ background: var(--red-bg); color: var(--red); }
.badge-blue{ background: var(--blue-bg); color: var(--blue); }

/* ── Add-car panel ───────────────────────────────────────────────────── */

.panel{
  border: 1px solid var(--border);
  background: #fafbfc;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  animation: fadeIn .2s ease both;
}

/* ── Feedback text (kept for existing #checkResult / #bookingResult) ──── */

.err{ color: var(--red); font-size: 13px; }
.ok{ color: var(--green); font-size: 13px; }

.result-box{ margin-top: 10px; font-size: 13px; }
.result-box:empty{ margin-top: 0; }

/* ── Spinner ─────────────────────────────────────────────────────────── */

.spinner{
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  display: inline-block;
  animation: spin .6s linear infinite;
}
.spinner-dark{
  border: 2px solid var(--border-strong);
  border-top-color: var(--brand);
}

/* ── Toasts ──────────────────────────────────────────────────────────── */

#toast-stack{
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(360px, calc(100vw - 32px));
}

.toast{
  background: var(--text);
  color: #fff;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastIn .25s ease both;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast.toast-out{ animation: toastOut .2s ease forwards; }
.toast-success{ background: var(--brand-dark); }
.toast-error{ background: var(--red); }

/* ── Animations ──────────────────────────────────────────────────────── */

@keyframes fadeIn{
  from{ opacity: 0; transform: translateY(4px); }
  to{ opacity: 1; transform: translateY(0); }
}
@keyframes spin{ to{ transform: rotate(360deg); } }
@keyframes shimmer{
  0%{ background-position: 100% 0; }
  100%{ background-position: -100% 0; }
}
@keyframes toastIn{
  from{ opacity: 0; transform: translateY(-10px); }
  to{ opacity: 1; transform: translateY(0); }
}
@keyframes toastOut{
  to{ opacity: 0; transform: translateY(-10px); }
}

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

/* ── Invoice (printable) ─────────────────────────────────────────────── */

.invoice-doc{
  font-family: var(--font);
  color: var(--text);
  max-width: 720px;
  margin: 0 auto;
  padding: 40px;
}
.invoice-head{
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 2px solid var(--text);
  padding-bottom: 20px;
  margin-bottom: 24px;
}
.invoice-brand{ display: flex; align-items: center; gap: 12px; }
.invoice-title{ text-align: right; }
.invoice-title h1{ font-size: 22px; }
.invoice-title p{ color: var(--text-mid); font-size: 12.5px; margin-top: 4px; }
.invoice-grid{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}
.invoice-block h3{
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-mid);
  margin-bottom: 8px;
}
.invoice-block p{ font-size: 13.5px; margin-bottom: 3px; }
.invoice-table{ width: 100%; border-collapse: collapse; margin-bottom: 24px; }
.invoice-table th, .invoice-table td{
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.invoice-table th{ background: #fafbfc; font-size: 11px; text-transform: uppercase; color: var(--text-mid); }
.invoice-fare{ text-align: right; font-size: 20px; font-weight: 700; margin-top: 8px; }
.invoice-footer{ margin-top: 32px; text-align: center; color: var(--text-faint); font-size: 12px; }
.invoice-actions{ text-align: center; margin-bottom: 24px; }
@media print{
  .invoice-actions{ display: none; }
  body{ background: #fff; }
}

/* ── Responsive ──────────────────────────────────────────────────────── */

@media (max-width: 1024px){
  .kpi-grid{ grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px){
  .wrap{ padding: var(--sp-2); }
  .kpi-grid{ grid-template-columns: repeat(2, 1fr); }
  .form-grid{ grid-template-columns: 1fr 1fr; }
  .card{ padding: 16px; }
  .invoice-grid{ grid-template-columns: 1fr; }
}

@media (max-width: 480px){
  .kpi-grid{ grid-template-columns: 1fr 1fr; }
  .form-grid{ grid-template-columns: 1fr; }
  .row-actions{ justify-content: flex-start; }
  button, .btn{ width: 100%; justify-content: center; }
  .row-actions button{ width: auto; }
  .topnav{ padding: 12px 16px; }
  .brand-sub{ display: none; }
}
