:root {
  --canvas: #f6f7f9;
  --panel: #ffffff;
  --line: #dde2ea;
  --ink: #121722;
  --muted: #667085;
  --accent: #0b6efb;
  --accent-soft: #e8f1ff;
  --danger: #b42318;
  --panel-shadow: 0 14px 30px rgba(18, 23, 34, 0.06);
  --panel-radius: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: "Segoe UI", Inter, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  appearance: none;
}

.dashboard-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 300px 1fr;
}

.filter-rail {
  border-right: 1px solid var(--line);
  background: #fff;
  padding: 20px 16px 24px;
}

.rail-brand {
  margin-bottom: 20px;
  padding: 0 4px;
}

.rail-eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.rail-title {
  margin: 6px 0 0;
  font-size: 15px;
  font-weight: 600;
}

.rail-nav {
  margin-bottom: 20px;
}

.nav-item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 10px 12px;
  text-align: left;
  transition: background-color 140ms ease, color 140ms ease;
}

.nav-item:hover {
  background: #f8fafc;
  color: var(--ink);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-item-label {
  font-size: 14px;
  font-weight: 500;
}

.rail-section {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.rail-section-heading {
  margin-bottom: 16px;
}

.rail-section-heading h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.rail-field-group {
  display: grid;
  gap: 12px;
}

.rail-field {
  display: grid;
  gap: 6px;
}

.rail-field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.rail-field input,
.chart-field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
}

.rail-checkbox-group {
  margin-top: 16px;
}

.checkbox-list {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 14px;
}

.checkbox-item input {
  accent-color: var(--accent);
}

.rail-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 500;
  padding: 10px 14px;
}

.button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.button-primary {
  flex: 1;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.button-secondary {
  background: #fff;
}

.button-square {
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

.button-small {
  padding: 7px 10px;
  font-size: 11px;
  text-transform: lowercase;
}

.dashboard-main {
  padding: 24px;
}

.dashboard-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.dashboard-title {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
}

.dashboard-copy {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.status-pill {
  max-width: 320px;
  border-radius: 999px;
  background: #1f2d3d;
  color: #fff;
  font-size: 13px;
  line-height: 1.3;
  padding: 10px 14px;
}

.status-pill.error {
  background: #fff1f2;
  color: var(--danger);
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--panel-radius);
  background: var(--panel);
  box-shadow: var(--panel-shadow);
}

.card + .card,
.card + .kpi-grid,
.kpi-grid + .card {
  margin-top: 20px;
}

.card-snapshot {
  background: linear-gradient(135deg, #ffffff, #f9fbfd 72%);
}

.card-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px 0;
}

.card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.card-copy {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.snapshot-grid {
  display: grid;
  gap: 12px;
  padding: 16px 18px 18px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.snapshot-card {
  border: 1px solid rgba(221, 226, 234, 0.92);
  border-radius: 14px;
  background: #fff;
  padding: 14px;
}

.snapshot-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.snapshot-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
}

.snapshot-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.snapshot-card-count {
  color: var(--muted);
  font-size: 12px;
}

.snapshot-metric {
  margin-top: 10px;
}

.snapshot-metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 11px;
}

.metric-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: #edf2f7;
  margin-top: 4px;
  overflow: hidden;
}

.metric-bar {
  height: 100%;
  border-radius: inherit;
}

.kpi-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.kpi-card {
  padding: 16px 18px;
}

.kpi-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.kpi-value {
  margin-top: 8px;
  font-size: 32px;
  font-weight: 600;
}

.kpi-hint {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.chart-card {
  background: linear-gradient(135deg, #ffffff, rgba(232, 241, 255, 0.32) 70%, #ffffff);
}

.chart-toolbar {
  display: grid;
  gap: 12px;
  padding: 16px 18px 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.chart-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.chart-field span {
  font-size: 12px;
  font-weight: 500;
}

.chart-field small {
  color: var(--muted);
}

.chart-stage {
  position: relative;
  padding: 16px 18px 18px;
}

.chart-canvas {
  width: 100%;
  max-width: 680px;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
}

.chart-actions {
  position: absolute;
  top: 30px;
  right: 30px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.empty-state {
  display: flex;
  min-height: 320px;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  font-size: 14px;
  padding: 24px;
  text-align: center;
}

.hidden {
  display: none !important;
}

.table-container {
  padding: 0 18px 18px;
  overflow-x: auto;
}

.report-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 960px;
}

.report-table th,
.report-table td {
  border-top: 1px solid #edf1f5;
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

.report-table thead th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-top: 0;
}

.report-table tbody tr:hover td {
  background: #fafcff;
}

.driver-cell strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
}

.driver-cell small {
  color: var(--muted);
  font-size: 12px;
}

.bar-cell {
  min-width: 220px;
}

.day-bar,
.timeline-bar {
  position: relative;
  height: 28px;
  overflow: hidden;
  border-radius: 8px;
  background: repeating-linear-gradient(90deg, #e2e8f0 0 1px, transparent 1px 25%);
  background-color: #f1f5f9;
}

.day-bar-segment,
.timeline-segment {
  position: absolute;
  inset-block: 4px;
  border-radius: 6px;
}

.day-bar-segment {
  background: rgba(11, 110, 251, 0.82);
}

.timeline-drive {
  background: #16a34a;
}

.timeline-stop {
  background: #0b6efb;
}

.empty-table {
  display: flex;
  min-height: 220px;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--line);
  border-radius: 16px;
  color: var(--muted);
  font-size: 14px;
  padding: 24px;
  text-align: center;
}

@media (max-width: 1280px) {
  .snapshot-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .dashboard-shell {
    grid-template-columns: 1fr;
  }

  .filter-rail {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .dashboard-header {
    flex-direction: column;
  }

  .chart-toolbar {
    grid-template-columns: 1fr;
  }

  .chart-actions {
    top: 24px;
    right: 24px;
  }
}

@media (max-width: 640px) {
  .dashboard-main {
    padding: 16px;
  }

  .snapshot-grid,
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .card-header,
  .snapshot-grid,
  .chart-toolbar,
  .chart-stage,
  .table-container {
    padding-left: 14px;
    padding-right: 14px;
  }
}
