/* ==========================================================================
   MotoBiz — Design tokens
   Dark fleet-ops theme: near-black surfaces, road-line orange accent.
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
  --navy: #0F1117;
  --navy-light: #3A3D4E;
  --slate: #9CA3AF;
  --slate-light: #6B7280;
  --paper: #0F1117;
  --card: #1A1D27;
  --amber: #F97316;
  --amber-dark: #EA6C0A;
  --teal: #22C55E;
  --teal-light: rgba(34, 197, 94, 0.14);
  --red: #EF4444;
  --red-light: rgba(239, 68, 68, 0.14);
  --blue: #60A5FA;
  --blue-light: rgba(96, 165, 250, 0.14);
  --gray-light: #2A2D3A;
  --line: #2A2D3A;
  --text: #F4F5F7;

  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.24);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.5;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--text);
  margin: 0 0 4px;
}

a { color: var(--amber); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ==========================================================================
   Layout shell
   ========================================================================== */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--line);
  color: #C8D3DE;
  display: flex;
  flex-direction: column;
  position: relative;
}

.sidebar-brand {
  padding: 22px 20px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand svg { flex-shrink: 0; }

.sidebar-brand .brand-text .name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  color: #fff;
  line-height: 1.1;
}
.sidebar-brand .brand-text .tag {
  font-size: 10.5px;
  color: var(--slate-light);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Route-line nav: a dashed vertical line runs through the nav like a delivery route */
.sidebar-nav {
  flex: 1;
  padding: 18px 0;
  position: relative;
}
.sidebar-nav::before {
  content: "";
  position: absolute;
  left: 30px; top: 8px; bottom: 8px;
  width: 0;
  border-left: 2px dashed rgba(255,255,255,0.14);
}
.nav-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--slate-light);
  padding: 14px 20px 6px 20px;
}
.nav-section-label:first-child { padding-top: 6px; }
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px 10px 20px;
  color: #B9C6D3;
  font-size: 13.5px;
  font-weight: 500;
  margin: 0 10px 2px;
  border-radius: 8px;
}
.nav-item .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: rgba(255,255,255,0.25);
  flex-shrink: 0;
  margin-left: 16px;
  z-index: 1;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(249,115,22,0.14); color: #fff; }
.nav-item.active .dot { background: var(--amber); box-shadow: 0 0 0 3px rgba(249,115,22,0.25); }
.nav-item .icon { width: 17px; text-align: center; z-index: 1; }

.sidebar-profile {
  padding: 12px 14px 4px;
  border-top: 1px solid var(--line);
}
.sidebar-profile .profile-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 6px; border-radius: 8px; margin-bottom: 2px;
}
.sidebar-profile .profile-row:hover { background: rgba(255,255,255,0.05); }
.sidebar-profile .avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: rgba(249,115,22,0.16); border: 1px solid rgba(249,115,22,0.3);
  color: var(--amber);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; font-size: 12px;
}
.sidebar-profile .profile-text { min-width: 0; }
.sidebar-profile .profile-text .name {
  font-size: 12.5px; font-weight: 600; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-profile .profile-text .email {
  font-size: 11px; color: var(--slate-light);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-profile .logout-link {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 6px; margin: 2px 0 6px; border-radius: 8px;
  font-size: 12.5px; font-weight: 500; color: #B9C6D3;
}
.sidebar-profile .logout-link:hover {
  background: rgba(239,68,68,0.1); color: var(--red); text-decoration: none;
}

.sidebar-footer {
  padding: 10px 20px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 11.5px;
  color: var(--slate-light);
}

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

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar h1 { font-size: 20px; }
.topbar .subtitle { font-size: 12.5px; color: var(--slate); font-weight: 400; }
.content { padding: 26px 28px; flex: 1; }

/* ==========================================================================
   Cards & stat tiles
   ========================================================================== */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: 15px; }
.card-body { padding: 20px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}
.stat-tile {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.stat-tile .stat-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--slate);
  font-weight: 600;
}
.stat-tile .stat-value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  margin-top: 6px;
}
.stat-tile .stat-sub { font-size: 12px; color: var(--slate-light); margin-top: 3px; }
.stat-tile.accent-amber { border-top: 3px solid var(--amber); }
.stat-tile.accent-teal { border-top: 3px solid var(--teal); }
.stat-tile.accent-blue { border-top: 3px solid var(--blue); }
.stat-tile.accent-red { border-top: 3px solid var(--red); }

/* ==========================================================================
   Section-label stat cards (dashboard / reports)
   ========================================================================== */
.section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--slate-light);
  margin: 22px 0 10px;
}
.section-label:first-child { margin-top: 0; }

.stat-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 8px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 16px;
}
.stat-card.trend-up { border-left-color: var(--teal); }
.stat-card.trend-down { border-left-color: var(--red); }
.stat-card.trend-brand { border-left-color: var(--amber); }
.stat-card .row-top {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 12px;
}
.stat-card .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--slate);
  font-weight: 600;
}
.stat-card .icon-chip {
  width: 26px; height: 26px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}
.stat-card .icon-chip.chip-success { background: var(--teal-light); }
.stat-card .icon-chip.chip-danger  { background: var(--red-light); }
.stat-card .icon-chip.chip-brand   { background: rgba(249,115,22,0.14); }
.stat-card .icon-chip.chip-warning { background: rgba(245,158,11,0.14); }
.stat-card .value {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.stat-card .value.text-up { color: var(--teal); }
.stat-card .value.text-down { color: var(--red); }

/* Simple CSS bar chart (no JS charting library) */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 22px;
  height: 190px;
  padding: 8px 6px 0;
}
.bar-chart .bar-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
}
.bar-chart .bar-col .bar-value {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--slate);
  margin-bottom: 6px;
  white-space: nowrap;
}
.bar-chart .bar-col .bar {
  width: 100%;
  max-width: 56px;
  border-radius: 6px 6px 0 0;
  min-height: 3px;
}
.bar-chart .bar-col .bar-label {
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--slate);
  text-align: center;
}

/* Grouped multi-series bar chart (e.g. revenue/expenses/maintenance trend) */
.trend-chart {
  display: flex;
  align-items: flex-end;
  gap: 18px;
  height: 190px;
  padding: 8px 4px 0;
  overflow-x: auto;
}
.trend-chart .trend-col {
  flex: 0 0 auto;
  min-width: 46px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
}
.trend-chart .trend-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 100%;
}
.trend-chart .trend-bars .bar {
  width: 10px;
  border-radius: 3px 3px 0 0;
  min-height: 2px;
}
.trend-chart .trend-label {
  margin-top: 8px;
  font-size: 11px;
  color: var(--slate);
  white-space: nowrap;
}

.legend-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.legend-row .legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--slate); }
.legend-row .legend-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }

/* Horizontal proportion bars (breakdowns / top lists) */
.prop-list { display: flex; flex-direction: column; gap: 11px; }
.prop-list .prop-row { display: flex; align-items: center; gap: 10px; }
.prop-list .prop-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.prop-list .prop-name { font-size: 13px; color: var(--text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prop-list .prop-track { width: 110px; height: 6px; background: var(--gray-light); border-radius: 4px; overflow: hidden; flex-shrink: 0; }
.prop-list .prop-fill { height: 100%; border-radius: 4px; }
.prop-list .prop-amount { font-size: 12px; color: var(--slate); width: 90px; text-align: right; flex-shrink: 0; }

/* CSS-only pie chart via conic-gradient */
.pie-chart-wrap { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.pie-chart { width: 150px; height: 150px; border-radius: 50%; flex-shrink: 0; }
.pie-legend { flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: 7px; }
.pie-legend .pie-legend-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.pie-legend .pie-legend-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.pie-legend .pie-legend-name { color: var(--slate); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pie-legend .pie-legend-amount { color: var(--slate-light); font-family: var(--font-mono); font-size: 11.5px; }

.period-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.period-btn {
  padding: 7px 13px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--slate);
  background: var(--gray-light);
  border: 1px solid transparent;
}
.period-btn:hover { color: var(--text); text-decoration: none; }
.period-btn.active { background: var(--amber); color: #fff; }

/* ==========================================================================
   Tables
   ========================================================================== */
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--slate);
  padding: 10px 14px;
  border-bottom: 2px solid var(--line);
  white-space: nowrap;
}
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.data-table tr:hover td { background: var(--navy-light); }
.data-table .row-actions { display: flex; gap: 10px; white-space: nowrap; }
.data-table .row-actions a { font-size: 12.5px; font-weight: 600; }

.empty-state {
  padding: 48px 20px;
  text-align: center;
  color: var(--slate);
}
.empty-state .icon { font-size: 30px; margin-bottom: 10px; }

/* Tracking / invoice codes styled like a vehicle plate */
.plate-code {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 12.5px;
  background: var(--gray-light);
  border: 1px dashed var(--slate-light);
  border-radius: 6px;
  padding: 3px 8px;
  color: var(--text);
  letter-spacing: 0.02em;
  display: inline-block;
}

/* ==========================================================================
   Badges
   ========================================================================== */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: capitalize;
}
.badge-gray  { background: var(--gray-light); color: var(--slate); }
.badge-blue  { background: var(--blue-light); color: var(--blue); }
.badge-amber { background: rgba(249,115,22,0.14); color: var(--amber); }
.badge-green { background: var(--teal-light); color: var(--teal); }
.badge-red   { background: var(--red-light); color: var(--red); }

/* ==========================================================================
   Buttons & forms
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none !important;
}
.btn-primary { background: var(--navy-light); color: #fff; }
.btn-primary:hover { background: #4B4F61; }
.btn-accent { background: var(--amber); color: #fff; }
.btn-accent:hover { background: var(--amber-dark); color: #fff; }
.btn-outline { background: transparent; border-color: var(--line); color: var(--text); }
.btn-outline:hover { border-color: var(--slate-light); }
.btn-danger { background: var(--red-light); color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-sm { padding: 6px 11px; font-size: 12px; }

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 13.5px;
  background: var(--card);
  color: var(--text);
}
.form-control:focus {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(249,115,22,0.12);
}
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.form-hint { font-size: 12px; color: var(--slate-light); margin-top: 4px; }

.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.filter-bar .form-control { width: auto; min-width: 160px; }
.search-input { min-width: 220px !important; }

/* ==========================================================================
   Alerts / flash messages
   ========================================================================== */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert-success { background: var(--teal-light); color: var(--teal); border-color: rgba(34,197,94,0.2); }
.alert-error   { background: var(--red-light); color: var(--red); border-color: rgba(214,69,69,0.2); }
.alert-info    { background: var(--blue-light); color: var(--blue); border-color: rgba(46,107,179,0.2); }

/* ==========================================================================
   Delivery route stepper (signature element)
   ========================================================================== */
.route-stepper { display: flex; align-items: center; margin: 6px 0 2px; }
.route-stepper .step {
  display: flex; flex-direction: column; align-items: center; flex: 1; position: relative;
}
.route-stepper .step .node {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--gray-light); border: 2px solid var(--slate-light);
  z-index: 1;
}
.route-stepper .step.done .node { background: var(--teal); border-color: var(--teal); }
.route-stepper .step.current .node { background: var(--amber); border-color: var(--amber-dark); }
.route-stepper .step .label { font-size: 10.5px; color: var(--slate); margin-top: 6px; text-align: center; }
.route-stepper .connector {
  flex: 1; height: 0; border-top: 2px dashed var(--line); margin-top: -16px; position: relative; top: -6px;
}
.route-stepper .connector.done { border-top-style: solid; border-top-color: var(--teal); }

/* ==========================================================================
   Login page
   ========================================================================== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  background-image:
    radial-gradient(circle at 15% 20%, rgba(249,115,22,0.10), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(34,197,94,0.18), transparent 40%);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--card);
  border-radius: 14px;
  padding: 34px 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}
.login-card .logo-row { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.login-card h2 { font-size: 19px; margin-bottom: 2px; }
.login-card .sub { font-size: 12.5px; color: var(--slate); margin-bottom: 22px; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 4px; }
.login-card .demo-note {
  margin-top: 18px; padding: 10px 12px; background: var(--gray-light);
  border-radius: 8px; font-size: 12px; color: var(--slate); font-family: var(--font-mono);
}

/* ==========================================================================
   Print styles (invoice)
   ========================================================================== */
@media print {
  .no-print { display: none !important; }
  .content { padding: 0; }
  body { background: #fff; }
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 880px) {
  .sidebar { position: fixed; left: -240px; top: 0; bottom: 0; z-index: 50; transition: left 0.2s; }
  .sidebar.open { left: 0; }
  .app-shell { display: block; }
  .content { padding: 18px; }
  .topbar { padding: 12px 16px; }
}
